netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock
@ 2017-09-27 12:25 Artem Savkov
  2017-09-27 12:31 ` Florian Westphal
  0 siblings, 1 reply; 3+ messages in thread
From: Artem Savkov @ 2017-09-27 12:25 UTC (permalink / raw)
  To: Florian Westphal
  Cc: Steffen Klassert, Herbert Xu, David S . Miller, netdev,
	linux-kernel, Artem Savkov

I might be wrong but it doesn't look like xfrm_state_lock is required
for xfrm_policy_cache_flush and calling it under this lock triggers both
"sleeping function called from invalid context" and "possible circular
locking dependency detected" warnings on flush.

Fixes: ec30d78c14a8 xfrm: add xdst pcpu cache
Signed-off-by: Artem Savkov <asavkov@redhat.com>
---
 net/xfrm/xfrm_state.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 0dab1cd79ce4..12213477cd3a 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -732,12 +732,12 @@ int xfrm_state_flush(struct net *net, u8 proto, bool task_valid)
 			}
 		}
 	}
+out:
+	spin_unlock_bh(&net->xfrm.xfrm_state_lock);
 	if (cnt) {
 		err = 0;
 		xfrm_policy_cache_flush();
 	}
-out:
-	spin_unlock_bh(&net->xfrm.xfrm_state_lock);
 	return err;
 }
 EXPORT_SYMBOL(xfrm_state_flush);
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock
  2017-09-27 12:25 [PATCH] xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock Artem Savkov
@ 2017-09-27 12:31 ` Florian Westphal
  2017-09-28 11:12   ` Steffen Klassert
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2017-09-27 12:31 UTC (permalink / raw)
  To: Artem Savkov
  Cc: Florian Westphal, Steffen Klassert, Herbert Xu, David S . Miller,
	netdev, linux-kernel

Artem Savkov <asavkov@redhat.com> wrote:
> I might be wrong but it doesn't look like xfrm_state_lock is required
> for xfrm_policy_cache_flush and calling it under this lock triggers both
> "sleeping function called from invalid context" and "possible circular
> locking dependency detected" warnings on flush.
> 
> Fixes: ec30d78c14a8 xfrm: add xdst pcpu cache
> Signed-off-by: Artem Savkov <asavkov@redhat.com>

You're right, its not needed (and wrong).

Acked-by: Florian Westphal <fw@strlen.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock
  2017-09-27 12:31 ` Florian Westphal
@ 2017-09-28 11:12   ` Steffen Klassert
  0 siblings, 0 replies; 3+ messages in thread
From: Steffen Klassert @ 2017-09-28 11:12 UTC (permalink / raw)
  To: Florian Westphal
  Cc: Artem Savkov, Herbert Xu, David S . Miller, netdev, linux-kernel

On Wed, Sep 27, 2017 at 02:31:03PM +0200, Florian Westphal wrote:
> Artem Savkov <asavkov@redhat.com> wrote:
> > I might be wrong but it doesn't look like xfrm_state_lock is required
> > for xfrm_policy_cache_flush and calling it under this lock triggers both
> > "sleeping function called from invalid context" and "possible circular
> > locking dependency detected" warnings on flush.
> > 
> > Fixes: ec30d78c14a8 xfrm: add xdst pcpu cache
> > Signed-off-by: Artem Savkov <asavkov@redhat.com>
> 
> You're right, its not needed (and wrong).
> 
> Acked-by: Florian Westphal <fw@strlen.de>

Applied to the ipsec tree, thanks everyone!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-28 11:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-27 12:25 [PATCH] xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock Artem Savkov
2017-09-27 12:31 ` Florian Westphal
2017-09-28 11:12   ` Steffen Klassert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).