Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp78732pxv; Wed, 30 Jun 2021 00:02:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvhaf1IABI5c9cZgC97Q7t5/Zwip06USslHLYgxyMCsNPOsjiQIzzkPTZq33BSX6i3NZ4t X-Received: by 2002:a17:906:718b:: with SMTP id h11mr33967166ejk.418.1625036523834; Wed, 30 Jun 2021 00:02:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625036523; cv=none; d=google.com; s=arc-20160816; b=HoOZg7nIoKMv8uMxNwLz5XmQrUQRPxUTvrleoK96YqSqEY/azldHIfDpML4ELFoZkw qcmkvNcqvmW8JbNkqxK41xvu+kiYIZWQyv6Oyf1ZlsWePyEUjEeEc1x+7Rj2ylxUJrbW 1vurrZ3KpZfOG0GVpIuY8UaqLDJnmRWtvJefzlaTODSiwIaDdF4Ix5S2xxRy2/gfbmPu R/UMF210dfB9ObOizovPrBFahXCqFOXFAtRHDQhhKZiB298Mieu1t1aXjhPYAhuIZEzT kD+l9OaEb6XF6ykc8mB/HQ34m3OK0tDnZI019VDmoHqCEtggqb3RP381MdgAeqtITODo IjlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=POzHKwmndiAzi/gmxQJDgL/cLzBbgN2iJCiK2/6Bcso=; b=UyusIsJHariHCcYbOqneaZZUIvvRhtjzmb4QkD96qv6cHH0BqEDxPTaZEv7SRynru/ SheXrLDbgM3UI+oGGHWmsF7TiNatuLFaY85EEfb7g5d/JJiiU8ID1a5raYzPiQP9L9xQ a/WKIZobIry5uIcBKwGw1FkLauKTIgr4srgO4uOc70+dAaHzcU4Y/czSPu+lNqnu5E57 x6lMTkBxFCaosBcAFCqu2nFnlMegYP+lUBUqh7PldQDakMGR8LAJzSrgXtv/SPg2Pes4 NvdG6kWOIvDg7xJ7q8t+c+XTUTxN3yhNASYhR+jlz+BW+JaF90RyHU3H8aobQXZRN+O0 txNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o25si19668470edv.414.2021.06.30.00.01.30; Wed, 30 Jun 2021 00:02:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232724AbhF3HAY (ORCPT + 99 others); Wed, 30 Jun 2021 03:00:24 -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!