Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4426417iob; Sun, 8 May 2022 12:19:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdI4XdTjAcamJcDzjM4uvYsXRSD59juuiHIAT1UNt95uHDb9GWnObJCzY28xKyKMLqW/so X-Received: by 2002:a17:907:1c25:b0:6f4:342f:51e6 with SMTP id nc37-20020a1709071c2500b006f4342f51e6mr11687498ejc.740.1652037596310; Sun, 08 May 2022 12:19:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652037596; cv=none; d=google.com; s=arc-20160816; b=KukWDqFKFi/h2Idzfci0+bkqfseBGe1SAxGBnWQSUe7M0lptMJW+1Y5ImyfMTlT7mP ki1HpdNRsBPc66d+ybbdzRCsDneDHQj4XHHHp+wcQDK3l4TySca4rLXf7iINZz5ijJCM pzGG1NlBtBugg2SFtWdAQhiUlJ5QV7SPbo9KG5DjpkE9Z4WA9YdXYsT2aqD90iKisIQ1 oSXAktz5bjGw3xVHEVZ8YcZtGvuo5QpzZ+E77h4jhAFGl13ZINYJN+lJcTSVgKWzxM8U YDez8gY+kcJx2pR7NxnlkXTiD9MnyOeXuQwh6hSjLEpTa9GKo3eG7o66ONXDH1bZs3z3 EhGA== 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=WrO/QgwpJUoFwCMp6uhXiVFq/2YvMtvI4L5BsFNOQDo=; b=vqHqCQibX2sBBor6NC8jcPiGBAFsSWR3yR/MLON4zmkSG7aGP5aJe7KSULtGEN1a2S aBuJfrdwzZOLqYrlydixaUqgz3+ne34+ySAj29n+5JuGg3kcnaCOqmYQyOSzGmSY3Dgo RlYT1QIgsEkUYcm6CeSdDQL8Yp4dHG0oR8zx1YJOno67od0wwfZ4N5ayzyNldWJkmoDd Jc3uuFaI3+AXkNcvStW0KZzcXCDuqD0UJmlh3559xp2exUZuyZO48hl7FNzmRhWLTn0U 8MlTPxALcHQxwwbB4IP5pRPKPOk0By8jAal9kyFMhERCnQ6qYu5aOCtYy4/IO3j8Dsa5 P7nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HyYh0HjS; 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 e8-20020a17090681c800b006f3a9007c63si10473506ejx.946.2022.05.08.12.19.32; Sun, 08 May 2022 12:19:56 -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=HyYh0HjS; 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 S1357935AbiEDRiJ (ORCPT + 99 others); Wed, 4 May 2022 13:38:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356873AbiEDRJr (ORCPT ); Wed, 4 May 2022 13:09:47 -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 DE772443C3; Wed, 4 May 2022 09:56:12 -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 A1261B82552; Wed, 4 May 2022 16:56:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53BE9C385A4; Wed, 4 May 2022 16:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683370; bh=mByOyQJpflwm3yp0gkyUjgqQy6QgDdF3JuD8miju9pY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HyYh0HjSv7N8IKB23eTSxZIPdNCM6JmD5w28QHG1TpCcC5ZzO1YIurnN5aL4ZpS54 4Z8TkuYKc9UgGK/OprBohpPEbKVHAmPySFQIA1/YPdMo4j97zchEepQ+D0yJXQaIfY YPlaJA+jQfs90S0SC9OB8e846hSXKshCkoRr1cxk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiubo Li , Jeff Layton , Aaron Tomlin , Ilya Dryomov Subject: [PATCH 5.17 041/225] ceph: fix possible NULL pointer dereference for req->r_session Date: Wed, 4 May 2022 18:44:39 +0200 Message-Id: <20220504153113.829524458@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153110.096069935@linuxfoundation.org> References: <20220504153110.096069935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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: Xiubo Li commit 7acae6183cf37c48b8da48bbbdb78820fb3913f3 upstream. The request will be inserted into the ci->i_unsafe_dirops before assigning the req->r_session, so it's possible that we will hit NULL pointer dereference bug here. Cc: stable@vger.kernel.org URL: https://tracker.ceph.com/issues/55327 Signed-off-by: Xiubo Li Reviewed-by: Jeff Layton Tested-by: Aaron Tomlin Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- fs/ceph/caps.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -2267,6 +2267,8 @@ retry: list_for_each_entry(req, &ci->i_unsafe_dirops, r_unsafe_dir_item) { s = req->r_session; + if (!s) + continue; if (unlikely(s->s_mds >= max_sessions)) { spin_unlock(&ci->i_unsafe_lock); for (i = 0; i < max_sessions; i++) { @@ -2287,6 +2289,8 @@ retry: list_for_each_entry(req, &ci->i_unsafe_iops, r_unsafe_target_item) { s = req->r_session; + if (!s) + continue; if (unlikely(s->s_mds >= max_sessions)) { spin_unlock(&ci->i_unsafe_lock); for (i = 0; i < max_sessions; i++) {