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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 7C406C11F68 for ; Wed, 30 Jun 2021 06:57:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B56E61A1D for ; Wed, 30 Jun 2021 06:57:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232746AbhF3HAZ (ORCPT ); Wed, 30 Jun 2021 03:00:25 -0400 Received: from mailout2.secunet.com ([62.96.220.49]:39740 "EHLO mailout2.secunet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232018AbhF3HAY (ORCPT ); Wed, 30 Jun 2021 03:00:24 -0400 Received: from cas-essen-01.secunet.de (unknown [10.53.40.201]) by mailout2.secunet.com (Postfix) with ESMTP id 0B058800056; Wed, 30 Jun 2021 08:57:54 +0200 (CEST) Received: from mbx-essen-01.secunet.de (10.53.40.197) by cas-essen-01.secunet.de (10.53.40.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 30 Jun 2021 08:57:53 +0200 Received: from gauss2.secunet.de (10.182.7.193) by mbx-essen-01.secunet.de (10.53.40.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 30 Jun 2021 08:57:53 +0200 Received: by gauss2.secunet.de (Postfix, from userid 1000) id 26EA4318040F; Wed, 30 Jun 2021 08:57:53 +0200 (CEST) Date: Wed, 30 Jun 2021 08:57:53 +0200 From: Steffen Klassert To: Frederic Weisbecker CC: LKML , Peter Zijlstra , "David S . Miller" , "Ahmed S . Darwish" , , Varad Gautam , Herbert Xu , Subject: Re: [PATCH] xfrm: Fix RCU vs hash_resize_mutex lock inversion Message-ID: <20210630065753.GU40979@gauss3.secunet.de> References: <20210628133428.5660-1-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210628133428.5660-1-frederic@kernel.org> X-ClientProxiedBy: cas-essen-02.secunet.de (10.53.40.202) To mbx-essen-01.secunet.de (10.53.40.197) X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 28, 2021 at 03:34:28PM +0200, Frederic Weisbecker wrote: > xfrm_bydst_resize() calls synchronize_rcu() while holding > hash_resize_mutex. But then on PREEMPT_RT configurations, > xfrm_policy_lookup_bytype() may acquire that mutex while running in an > RCU read side critical section. This results in a deadlock. > > In fact the scope of hash_resize_mutex is way beyond the purpose of > xfrm_policy_lookup_bytype() to just fetch a coherent and stable policy > for a given destination/direction, along with other details. > > The lower level net->xfrm.xfrm_policy_lock, which among other things > protects per destination/direction references to policy entries, is > enough to serialize and benefit from priority inheritance against the > write side. As a bonus, it makes it officially a per network namespace > synchronization business where a policy table resize on namespace A > shouldn't block a policy lookup on namespace B. > > Fixes: 77cc278f7b20 (xfrm: policy: Use sequence counters with associated lock) > Cc: stable@vger.kernel.org > Cc: Ahmed S. Darwish > Cc: Peter Zijlstra (Intel) > Cc: Varad Gautam > Cc: Steffen Klassert > Cc: Herbert Xu > Cc: David S. Miller > Signed-off-by: Frederic Weisbecker Your patch has a conflicht with ("commit d7b0408934c7 xfrm: policy: Read seqcount outside of rcu-read side in xfrm_policy_lookup_bytype") from Varad. Can you please rebase onto the ipsec tree? Btw. Varad, your above mentioned patch tried to fix the same issue. Do we still need it, or is it obsolete with the fix from Frederic? Thanks!