From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33AB7C3A589 for ; Tue, 20 Aug 2019 09:38:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0F73C20673 for ; Tue, 20 Aug 2019 09:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729469AbfHTJiD (ORCPT ); Tue, 20 Aug 2019 05:38:03 -0400 Received: from Chamillionaire.breakpoint.cc ([193.142.43.52]:33672 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728414AbfHTJiC (ORCPT ); Tue, 20 Aug 2019 05:38:02 -0400 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1i00aW-0003Z8-K3; Tue, 20 Aug 2019 11:38:00 +0200 Date: Tue, 20 Aug 2019 11:38:00 +0200 From: Florian Westphal To: Vakul Garg Cc: Florian Westphal , "netdev@vger.kernel.org" Subject: Re: Help needed - Kernel lockup while running ipsec Message-ID: <20190820093800.GN2588@breakpoint.cc> References: <20190819173810.GK2588@breakpoint.cc> <20190820092303.GM2588@breakpoint.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Vakul Garg wrote: > > > > -----Original Message----- > > From: Florian Westphal > > Sent: Tuesday, August 20, 2019 2:53 PM > > To: Vakul Garg > > Cc: Florian Westphal ; netdev@vger.kernel.org > > Subject: Re: Help needed - Kernel lockup while running ipsec > > > > Vakul Garg wrote: > > > > > With kernel 4.14.122, I am getting a kernel softlockup while > > > > > running single > > > > static ipsec tunnel. > > > > > The problem reproduces mostly after running 8-10 hours of ipsec > > > > > encap > > > > test (on my dual core arm board). > > > > > > > > > > I found that in function xfrm_policy_lookup_bytype(), the policy > > > > > in variable > > > > 'ret' shows refcnt=0 under problem situation. > > > > > This creates an infinite loop in xfrm_policy_lookup_bytype() and > > > > > hence the > > > > lockup. > > > > > > > > > > Can some body please provide me pointers about 'refcnt'? > > > > > Is it legitimate for 'refcnt' to become '0'? Under what condition > > > > > can it > > > > become '0'? > > > > > > > > Yes, when policy is destroyed and the last user calls > > > > xfrm_pol_put() which will invoke call_rcu to free the structure. > > > > > > It seems that policy reference count never gets decremented during packet > > ipsec encap. > > > It is getting incremented for every frame that hits the policy. > > > In setkey -DP output, I see refcnt to be wrapping around after '0'. > > > > Thats a bug. Does this affect 4.14 only or does this happen on current tree > > as well? > > I am yet to try it on 4.19. > Can you help me with the right fix? Which part of code should it get decremented? > I am not conversant with xfrm code. Normally policy reference counts get decremented when the skb is free'd, via dst destruction (xfrm_dst_destroy()). Do you see a dst leak as well?