Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1977091rwe; Fri, 2 Sep 2022 06:53:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR5ixG0LDj5wQbemrVJm7/sYDf+CeSN+bzVIcKrvlzOUoIyI7y+GuZKd9cYsLJ3sXp6SWr59 X-Received: by 2002:a17:90b:4b81:b0:1fd:d736:9d04 with SMTP id lr1-20020a17090b4b8100b001fdd7369d04mr5028142pjb.121.1662126826866; Fri, 02 Sep 2022 06:53:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662126826; cv=none; d=google.com; s=arc-20160816; b=cY5W9Pul30TSJiRaJA/xWKZGjVVE3Wnq7DKcsBwmILLEKispyr49MKaoI7R3l3lw9M 4huxXrdz5AnclFrHBkZ1ntWWRzZ0lyVsuQpgi+bkMB1ehKQBVV+sHsJLuzv1l/MktOrh /BhCAuxeA1DkAx+kOoK1TG8s1g4g4avWJ4TRwn8jAUe2smq7Z3XBz061EfcMbMGuNDaD eYmVqwTzzGPDTX0ojh+eR5/8oK4zaD5I2Wdb0DQK4JIwzt9TCWGGEkQeDZ7Wz/m339RY /S0hcf2Unc+/DtbOlLgZVvOk4HjiZSIBYe4AuqL4R9kIOLqB8LAjE4DadnyAYHoTeTKY 8cJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9GY7sTILjiGhypPJVJTsotcgyvyDDfL4pIjWz0Dt2HE=; b=K21jsGUNFbaqqXWuC5RX+tRzofOWRKq5dRAqHE/CZvT/wV9reZoHInnRUhmqlduFEy cnqKTX4/8u+sab9z+ms8NRQ9E8M+yPW92yavyC3MAYHBMIQxZ0OSkFf8wvNXbmjGkzc6 uV8bmuSHjN7yoyJCF6963+eOjAupYvH4w706QYPSXtQb95GIGAGJ52MxAI5s/smVtmZM 02TDSIIAr8XB0QmhpvqARLpjr2bikxG6VaIt3gSFwFt4vh51isyyS/sjih/P6biOruOB /h6XfSCZvYXftrVisZBULvwIzf7FZUnMdtMV+THz2N+/bl5Rb6JdwOYVgmNNgqBqHr/W 0hiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1QO10Ysz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b20-20020a637154000000b004307ac80d22si2042299pgn.332.2022.09.02.06.53.36; Fri, 02 Sep 2022 06:53:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1QO10Ysz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236115AbiIBMWQ (ORCPT + 99 others); Fri, 2 Sep 2022 08:22:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235811AbiIBMVP (ORCPT ); Fri, 2 Sep 2022 08:21:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A851E5F126; Fri, 2 Sep 2022 05:20:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4006E620E6; Fri, 2 Sep 2022 12:20:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DF5EC433C1; Fri, 2 Sep 2022 12:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662121242; bh=yjFbBlaMaiW1xyHU4qJxXDx2fbTonaU5u23wM7iThqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1QO10Ysz98stHZCAWoFD9yL01dBiz8wHxBu/cdrCwpnJQRCAxR/NPzuXfqHjrAQuv +rfB/0F9bTaxzSeDN75VRIyRiO8b/5Uhz4+Zb/BdPW3ybE/lzJWys8mBIntjKdj0wu gqBi65WytJoDm1IPc6AfZi3Q4VRpP2nxyU10DnoU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abhishek Shah , Herbert Xu , Steffen Klassert , Sasha Levin Subject: [PATCH 4.9 03/31] af_key: Do not call xfrm_probe_algs in parallel Date: Fri, 2 Sep 2022 14:18:29 +0200 Message-Id: <20220902121356.874120507@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121356.732130937@linuxfoundation.org> References: <20220902121356.732130937@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Herbert Xu [ Upstream commit ba953a9d89a00c078b85f4b190bc1dde66fe16b5 ] When namespace support was added to xfrm/afkey, it caused the previously single-threaded call to xfrm_probe_algs to become multi-threaded. This is buggy and needs to be fixed with a mutex. Reported-by: Abhishek Shah Fixes: 283bc9f35bbb ("xfrm: Namespacify xfrm state/policy locks") Signed-off-by: Herbert Xu Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/key/af_key.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/key/af_key.c b/net/key/af_key.c index 0737fc7b7ebdb..88d4a3a02ab72 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -1724,9 +1724,12 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sad pfk->registered |= (1<sadb_msg_satype); } + mutex_lock(&pfkey_mutex); xfrm_probe_algs(); supp_skb = compose_sadb_supported(hdr, GFP_KERNEL | __GFP_ZERO); + mutex_unlock(&pfkey_mutex); + if (!supp_skb) { if (hdr->sadb_msg_satype != SADB_SATYPE_UNSPEC) pfk->registered &= ~(1<sadb_msg_satype); -- 2.35.1