From patchwork Mon Jul 31 11:38:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13334463 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F0F1182A0 for ; Mon, 31 Jul 2023 11:38:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3B4EC433C8; Mon, 31 Jul 2023 11:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690803521; bh=4Kut+Aj34e0b4FvRLDaGTDfUM4AGVvNXmN+OkJ4YXXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nZmMlhhZ3HC73+irFN/YqJ6Ws5nW8xV53e8kw/p0PoPh1SyL5qxdVlb3bivSjg0BC SzjeIATzrh23JxGezenpCat3hoT0ueIGMG1QPzCGai62NbcGwDAGGqkubsCjZuo4fF c3k+DH0hj1IHqlmiCBgmLSrCrsfXjBj0x5j9yLYkeBuxIIy1cGaEK5+Khnfl0KgGhk Ux2aRG5Vcj7aL/8xlYhaUshsYVj8mGqxRdkddV6Jh5BZ3JqIMifR7EOD9hQyVsZBU0 ATYflLiR9TsX8IV1CqoMc30c2aqoDLch+w7OTUEGL79PknSuaXWQcRlYU61jhhQPhV mIdtbWfRgZu6Q== From: Leon Romanovsky To: Steffen Klassert Cc: Leon Romanovsky , "David S. Miller" , Eric Dumazet , Herbert Xu , Jakub Kicinski , netdev@vger.kernel.org, Paolo Abeni , Raed Salem Subject: [PATCH ipsec-rc 1/2] xfrm: delete offloaded policy Date: Mon, 31 Jul 2023 14:38:26 +0300 Message-ID: <8a4865f5b78314be70cb8540027cc48f86d45d89.1690803052.git.leon@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Leon Romanovsky The policy memory was released but not HW driver data. Add call to xfrm_dev_policy_delete(), so drivers will have a chance to release their resources. Fixes: 919e43fad516 ("xfrm: add an interface to offload policy") Signed-off-by: Leon Romanovsky --- net/xfrm/xfrm_user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index c34a2a06ca94..5a117aac4274 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -2336,6 +2336,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, NETLINK_CB(skb).portid); } } else { + xfrm_dev_policy_delete(xp); xfrm_audit_policy_delete(xp, err ? 0 : 1, true); if (err != 0) From patchwork Mon Jul 31 11:38:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13334464 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 845FF182A0 for ; Mon, 31 Jul 2023 11:38:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8C6EC433C7; Mon, 31 Jul 2023 11:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690803525; bh=uidl4fUimwXietfKpV1dwJxCa9qfVHrQL0IdL98DeT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MzWCUbpJ8t5gEacDnviEmMdxhTz08ixuHIau1xPcgUB6RbwYFCG66a3n8ZozsILt0 Ija1zyy9L/P/hSQzlmWuE+06tSRjoV0KIHqo10PnmknbDv8l5Rn5zQADfeTPK75yOj jLfR6DwIgGj1TVFXCgZ9uNAaPLJ0gyqgdBhgMjR+yWUXE7PiinETPOAOvJ1/MMGuMD KdkJI6qlSP8+qv6xE178C/TDHzLfkB/CUIyM9tt+Q1FWtnsXGH+m9fb2l3l8oqdE9t zr+bOnQCQEaTGhnS6vQPrd3CHSjEyd85Fd2wC/vl4nVdhk8BhHvFW29iYXYlHz/tWQ ZaFKkRHP5NaOw== From: Leon Romanovsky To: Steffen Klassert Cc: Leon Romanovsky , "David S. Miller" , Eric Dumazet , Herbert Xu , Jakub Kicinski , netdev@vger.kernel.org, Paolo Abeni , Raed Salem Subject: [PATCH ipsec-rc 2/2] xfrm: don't skip free of empty state in acquire policy Date: Mon, 31 Jul 2023 14:38:27 +0300 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Leon Romanovsky In destruction flow, the assignment of NULL to xso->dev caused to skip of xfrm_dev_state_free() call, which was called in xfrm_state_put(to_put) routine. Instead of open-coded variant of xfrm_dev_state_delete() and xfrm_dev_state_free(), let's use them directly. Fixes: f8a70afafc17 ("xfrm: add TX datapath support for IPsec packet offload mode") Signed-off-by: Leon Romanovsky --- include/net/xfrm.h | 1 + net/xfrm/xfrm_state.c | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 151ca95dd08d..363c7d510554 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -1984,6 +1984,7 @@ static inline void xfrm_dev_state_free(struct xfrm_state *x) if (dev->xfrmdev_ops->xdo_dev_state_free) dev->xfrmdev_ops->xdo_dev_state_free(x); xso->dev = NULL; + xso->type = XFRM_DEV_OFFLOAD_UNSPECIFIED; netdev_put(dev, &xso->dev_tracker); } } diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 49e63eea841d..bda5327bf34d 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -1324,12 +1324,8 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr, struct xfrm_dev_offload *xso = &x->xso; if (xso->type == XFRM_DEV_OFFLOAD_PACKET) { - xso->dev->xfrmdev_ops->xdo_dev_state_delete(x); - xso->dir = 0; - netdev_put(xso->dev, &xso->dev_tracker); - xso->dev = NULL; - xso->real_dev = NULL; - xso->type = XFRM_DEV_OFFLOAD_UNSPECIFIED; + xfrm_dev_state_delete(x); + xfrm_dev_state_free(x); } #endif x->km.state = XFRM_STATE_DEAD;