Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3052806rwe; Mon, 29 Aug 2022 05:11:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR46mOIsb7T9pjuO5yuR1nBmMjk8yKXWREuMCU7Cazp0CHja/ZSevH8RsL5vULSCrLP1zMD4 X-Received: by 2002:a05:6402:2029:b0:447:aae3:4fa3 with SMTP id ay9-20020a056402202900b00447aae34fa3mr16485328edb.104.1661775091891; Mon, 29 Aug 2022 05:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661775091; cv=none; d=google.com; s=arc-20160816; b=vmE6l2JgG0SwR3AucaYV5p0eQ7Mmz+D9bR2ECCDFnNG8wAWH+UR9Equ6EQ6dShb/tq AkxRhed6ySbbw01i2NvJBwQSranz27V8NQ9Fr3urRtVpNJuF2ctnX0/TYtlBFcLGA+2v gaHfaUlTenyPKqeWm0fZf8mTicQo3dX4uCOwkMSsIagPY4LxHBNlZeuQQgTpRmFZAq2i +sBOfdVMQemjvWp4y2/pGHPHpkZbIAzgwJ4MW7gfZ0CjDIm7fG7tm4ZKWOQ/tkOQXd18 fUTe8g7peHYBEtN+v6yho1eNKaEP9NH3hMZgfe/OAjIf2xb7h2ycSVk42+C4c8+siZnR d+pQ== 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=E5VTk1KQ8PU1x5BHVqzpqbim9sWGDZR8zZxaalh/C6Q=; b=aTwCOCTbes90g3eeJBORw2k/K8eNBRq8r8xrslRTnFfdS6X4lLQFAvR6ZerrZR5LfP UbeUV03b3KFzM23AcJi2FsenVSa3NxAqEfGpiBtLeDumjk72EA4FU/sjmBOOhuvyKMWu HOEwxqNKqILafJ55W3zh6pkEN9QVuli6lVlK+1/0DuSbtgYkWb0IZDI+jaZZsjNp9f5W b3WEBWLJXlwXI2qWKxJZFgTC/KoFR0jD/sa7KcCZWcoTsRCxuWXuypyqtlZEbZwqhsLJ qI+8SrI+F8siUsx+pzB50FNp7C1H7sj86q2LDeYvBdBHa0bxHRxNfd0sshisz0+zfvum w2/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WGarHegp; 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 gn23-20020a1709070d1700b007419b5feb98si1556539ejc.255.2022.08.29.05.11.06; Mon, 29 Aug 2022 05:11:31 -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=WGarHegp; 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 S231970AbiH2LZg (ORCPT + 99 others); Mon, 29 Aug 2022 07:25:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231940AbiH2LXo (ORCPT ); Mon, 29 Aug 2022 07:23:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E42021208E; Mon, 29 Aug 2022 04:15:05 -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 ams.source.kernel.org (Postfix) with ESMTPS id 595AAB80F00; Mon, 29 Aug 2022 11:04:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B598C433D6; Mon, 29 Aug 2022 11:04:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771055; bh=IOjqcHeflpnbKlkEEE7LINxAisCrYJnMtE2cW17fZvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WGarHegpd+CVjLpeR4ZzAqksgXXMWXwTqlNbdPiFXNoSADxy7tv37WuHUcGCLB6zi ZiWgk1UB0VTcEPByKeXd9tVjN3p8mR6J3jelgFbc+ZjQzJ0OwNnsWH4tHqZaz8Kf7h C1n+IwTh6fq/3EVc3hllOv8cVkV72edBnf+PcmIU= 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 5.10 14/86] af_key: Do not call xfrm_probe_algs in parallel Date: Mon, 29 Aug 2022 12:58:40 +0200 Message-Id: <20220829105757.105259253@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105756.500128871@linuxfoundation.org> References: <20220829105756.500128871@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 2aa16a171285b..05e2710988883 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -1701,9 +1701,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