Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4808016iob; Mon, 9 May 2022 02:02:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBtQtzC29NVdBPp+klmLvKPWj7Zlu3+iFO2we2hgp5T2XDgAF0RsY9MK5uSonsx1+2kV08 X-Received: by 2002:a17:90b:1e4b:b0:1dc:7b66:55d6 with SMTP id pi11-20020a17090b1e4b00b001dc7b6655d6mr17653675pjb.80.1652086944234; Mon, 09 May 2022 02:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652086944; cv=none; d=google.com; s=arc-20160816; b=Ln4X0OAuDl78OgN/bug/0w4WB78hJ2xj6oA1c/uCoVrpOXT5sx6vPbVIS9P3O9WEsh /cXBxV5+2fn3wKVOw0Ms2PLKSNJjof9w/DrpOfHjbuXch8MEdcyDZDRMJRsjGzuhP9AZ ngIzsSvW1bqURek775E8fQbUp2BDhQjjtPnLsYKfZ0xKAo3QjrkkHJ98l9Ds7VNM8yye pD6n1+41h9Swlb7IsLb77AdXFb+2nPkt4ugljUnwFSpTx+NNxS2mTAC26i6Co6gW+Q8l HIA9WJJhLZtFQqZLbdjozxI/49aWiXySeRItfr9JAw+yJsEUcmmPjNNQGMuDdfwwaacZ 6Hiw== 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=6fxdWiang4Gj9hxd8jeozv5y3CfQqV3kUlEIHbPx0PU=; b=jxEetp1elp8cY7Shj/jfI45zclRJOt7bcDDuni1k6HkNsD/yoEtB1gCilCy1/RrTLY J0ONXaFMqF9YlCJbWnbv5+OPBSBkE5+ii6Uzjbl5pfWw0e587iF+qdzmdfzQ8Mq/o/TD CLbubtmrQyUb3lzG7VYf/4UB9Dc5k4IkpXnWfLzADye9rP4WygNZ2p2TkOK5xM8UQyZi zN9ezDOdYULH5RhNbEJpM5cDYESxBPd7TE0P7Un9IJIzjJXc51ew3nu/JeNwvMqfhBzQ UEwpm1I3fd0inLuZPpnKBsTSDt45/0VlF95/EuYtHWPyJovcTkWH/BpVHRbxtuX/LSGL U6HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iw4PR6eU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q13-20020a17090311cd00b00153b2d165b0si12380620plh.440.2022.05.09.02.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 02:02:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iw4PR6eU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 216CD1ED295; Mon, 9 May 2022 01:49:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357855AbiEDRZK (ORCPT + 99 others); Wed, 4 May 2022 13:25:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355293AbiEDREQ (ORCPT ); Wed, 4 May 2022 13:04:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D0014EA2F; Wed, 4 May 2022 09:52:55 -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 3F7C66181D; Wed, 4 May 2022 16:52:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91412C385A5; Wed, 4 May 2022 16:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683169; bh=q4qRcixjZfwyrHDVj2jNoFv5DwrF7PikIhtG3Ad2Q6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iw4PR6eUCDZRXRe6XfnYbSrASzRhft+O3OY76LAYb/Q80dUbGW2hHCrBCsOU/242k trUGeRwBtSFhH2iVQmhtzhnJVz3PBmDuPX3UT2zQAjPEYfEXKkAmj10ZIhbYlS6uy7 y4w64k4l6GZnJUM/TTdzj1oc+kRByAscwzvKOhMQ= 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.15 034/177] ceph: fix possible NULL pointer dereference for req->r_session Date: Wed, 4 May 2022 18:43:47 +0200 Message-Id: <20220504153056.012271165@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@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=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 @@ -2266,6 +2266,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++) { @@ -2286,6 +2288,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++) {