Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1072237rwb; Sat, 14 Jan 2023 13:37:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXuOV85X3Qz5RENadmJP/C57WeSDgNyFjw8Jl1zhgR4dais3Yn19Zf/qQWHFUtq4lwdHITVq X-Received: by 2002:a05:6a20:12ca:b0:ab:e8a7:6137 with SMTP id v10-20020a056a2012ca00b000abe8a76137mr123087485pzg.3.1673732251064; Sat, 14 Jan 2023 13:37:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673732251; cv=none; d=google.com; s=arc-20160816; b=fFMeflYbWG2b71/nAMOKZ/4mxjTUELgVd3mLRKxUnGeRJ0ookTahcUbcM+e2wmPJgt fXRim1D9Uu5My+abKmI4YZtPXf373nbcKsI7apH3ASt+2A2kSCyyssWbEJsNV4+7jaSs tQnYGzTHse7zbCeciNOq4m+lyJi36lQeXrMdhLese9TvWb3D1kBNtYXfVlE9yjHJqIoB bFMnYdrDGUwwDNFZW3i7jIkTY/XI3/zD9M9eNXrcRV6oJt54Y/OW0SfDJV8e1CXUffeY Ha78cQXKizCvS/5PuZpx+QROYKoaWBe7NwHoE8QVl49vEeMlv0PBvo8lnipJ5YrVdcG4 I1ng== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=hVgFEbttc6O8/g5okwEBjsKPQRLGn8nsRQ3DxCuxhlY=; b=gL2BfKJh94Qd3z4ioTD0CPY+slI/FplNG9ZLFK/5OtQ5U9eSJLhZOQ9WT/YwXEVcHg lK8ol+7y7hF2QojwwOusVwVffZpnyu1DkuARQ8bhXRZrJb4UfuArcD8mX5M75sHQnoTE kjqAQwIZoeJBjfhyaWZtp8CUhU+1J7mzet905REmmqVArCXeAjiQ+Q3l2tCzl0XBnw/I bLYkUurX4lKkfmXrrKxBeCP6yNI4D8fNjMAe6pz7BFdDXp32oNtOJcglBXUQzR3CiPLh /+9mYhG8/m4slKbvunYLXxJelo9Y0VnuglgrhUMYjcUx9sjBc4MKsKxS+5IFZXieORen mfOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=BcyF5+C3; 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=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m27-20020a634c5b000000b00473d2108701si25095733pgl.198.2023.01.14.13.37.24; Sat, 14 Jan 2023 13:37:31 -0800 (PST) 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=@ispras.ru header.s=default header.b=BcyF5+C3; 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=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230465AbjANU7T (ORCPT + 52 others); Sat, 14 Jan 2023 15:59:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbjANU7O (ORCPT ); Sat, 14 Jan 2023 15:59:14 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 264A27EFF; Sat, 14 Jan 2023 12:59:13 -0800 (PST) Received: from fedcomp.intra.ispras.ru (unknown [46.242.14.200]) by mail.ispras.ru (Postfix) with ESMTPSA id 1A7D4419E9F2; Sat, 14 Jan 2023 20:59:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 1A7D4419E9F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1673729951; bh=hVgFEbttc6O8/g5okwEBjsKPQRLGn8nsRQ3DxCuxhlY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BcyF5+C3x7xIhQoNgim15t22u7NHTpDrlcgcg+HrA7CtXHvFJjv4TyLlo/0PYNR1/ iqEr+bBGZ3A7Q+thxIAdeUXn4f59964Kn9EGjcYLdSTv7uYapTz9/KoOgGDfpJdHbR VoMb+iRZwXadlGKfO8lHmHulEGAa3ClpU4nO3gPM= From: Fedor Pchelkin To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Fedor Pchelkin , Steffen Klassert , Herbert Xu , "David S. Miller" , Jakub Kicinski , Sasha Levin , Nicolas Dichtel , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org, syzbot+3d9866419b4aa8f985d6@syzkaller.appspotmail.com Subject: [PATCH 5.10 1/1] xfrm: fix rcu lock in xfrm_notify_userpolicy() Date: Sat, 14 Jan 2023 23:58:49 +0300 Message-Id: <20230114205850.176370-2-pchelkin@ispras.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230114205850.176370-1-pchelkin@ispras.ru> References: <20230114205850.176370-1-pchelkin@ispras.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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: Nicolas Dichtel commit 93ec1320b0170d7a207eda2d119c669b673401ed upstream. As stated in the comment above xfrm_nlmsg_multicast(), rcu read lock must be held before calling this function. Reported-by: syzbot+3d9866419b4aa8f985d6@syzkaller.appspotmail.com Fixes: 9856c3a129dd ("xfrm: notify default policy on update") Signed-off-by: Nicolas Dichtel Signed-off-by: Steffen Klassert Signed-off-by: Fedor Pchelkin --- net/xfrm/xfrm_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index d9841f44487f..b5a517916895 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -1920,6 +1920,7 @@ static int xfrm_notify_userpolicy(struct net *net) int len = NLMSG_ALIGN(sizeof(*up)); struct nlmsghdr *nlh; struct sk_buff *skb; + int err; skb = nlmsg_new(len, GFP_ATOMIC); if (skb == NULL) @@ -1938,7 +1939,10 @@ static int xfrm_notify_userpolicy(struct net *net) nlmsg_end(skb, nlh); - return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_POLICY); + rcu_read_lock(); + err = xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_POLICY); + rcu_read_unlock(); + return err; } static bool xfrm_userpolicy_is_valid(__u8 policy) -- 2.34.1