Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1139844iob; Wed, 4 May 2022 15:45:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+JMWp/n4+OTgXIt2jpbOMfHfkv004s7q/w2bBCjQ2Bb3xEXFqbDagMvkT/5+d3j0WEp02 X-Received: by 2002:a05:6402:1910:b0:428:1817:6f2f with SMTP id e16-20020a056402191000b0042818176f2fmr4849215edz.354.1651704330970; Wed, 04 May 2022 15:45:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651704330; cv=none; d=google.com; s=arc-20160816; b=yXWjK81LhwDZNwf00UKpDbE3nG3R1l8u0ySY5VSO79hDvlO8y5BooOez4NttTIGl4F /31gXS2q38GfStYa42rkh21URedZCaPhNd9OyDktMNxnl+Shou/QtI75W1UVX0zXVR+/ 1+ajOltIH2Mx1A4GWVGEGG8N7v7sGAfJU5379CxUC7AVYLV3jkiEkfhtBxv9tDsaq6i/ PvmdM8XqajpIwOqraO+CgGw7j3dyNioGrTj/RQ98kYmbrt2CL3SIVQRSw4mZ0nrx8UmG b5SmXKtTfVTZzRWsyfN57YiGpqvzC+zHyAtxCDVxHUWpbhMy4hyu+oYw66aBNaRlKgsl Io1Q== 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=+orneaILHWTXoTDT9chimh68G7IDnQfpehNq4VHD57I=; b=U4lf18WeUPvs3xjC7ayBb0lCUzyr7XOAfh9cV6pSEPt6w10sRBEzH0Qkh7LIu+6voj DkxVgkadZSzyBv0dFa6sgB7knZRCoyk6kat6GZUBMDiT9Bh3kXDZReYBhoOHUxG8Pnc+ HyhWstz2ID3/VBM5nIQ072CJzcEG2hUVv+ppoPn02PDAuwORdLtGdinFNUTJQFcOnjI1 UQh1uKVgnv3KxqWf3QqOQsXmg0IhBhqmkylKUG9jVtWjzNMx9tHTIxZImrnkQ3L5nDaq 9U4wSYcLBHdhm5abTQqgJY5J0DoDk+DGhuDMKt8TlLTpgPFQDfQ0f6zYqXgasNuQkxCw iq0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nS7JrE10; 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 fy12-20020a1709069f0c00b006e8c13b56e5si83036ejc.804.2022.05.04.15.45.07; Wed, 04 May 2022 15:45:30 -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=nS7JrE10; 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 S1358902AbiEDRmw (ORCPT + 99 others); Wed, 4 May 2022 13:42:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355826AbiEDRKn (ORCPT ); Wed, 4 May 2022 13:10:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 348314A91F; Wed, 4 May 2022 09:57:25 -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 E8014B8279A; Wed, 4 May 2022 16:57:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E9C7C385AF; Wed, 4 May 2022 16:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683441; bh=e+oxjEJlR1PMHd11JKjXVmZGlgC98O91GpA6vAZb0A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nS7JrE10OrN6b+JGFmFPVN2BqUK+PrZknazplH50d2INDz1NSc9MX3AEblp2DE75I SJvhOHuncXCIT5e7BzIYk/zebDtsEuyVxFALt77O+BklSwVEE6xsOYoljFecfCjhpL uW9rHzd4keEztQ3F0/EnCqn8PyDJoXbxliOJSvvI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ying Xu , Xin Long , Marcelo Ricardo Leitner , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 109/225] sctp: check asoc strreset_chunk in sctp_generate_reconf_event Date: Wed, 4 May 2022 18:45:47 +0200 Message-Id: <20220504153120.352753278@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: Xin Long [ Upstream commit 165e3e17fe8fe6a8aab319bc6e631a2e23b9a857 ] A null pointer reference issue can be triggered when the response of a stream reconf request arrives after the timer is triggered, such as: send Incoming SSN Reset Request ---> CPU0: reconf timer is triggered, go to the handler code before hold sk lock <--- reply with Outgoing SSN Reset Request CPU1: process Outgoing SSN Reset Request, and set asoc->strreset_chunk to NULL CPU0: continue the handler code, hold sk lock, and try to hold asoc->strreset_chunk, crash! In Ying Xu's testing, the call trace is: [ ] BUG: kernel NULL pointer dereference, address: 0000000000000010 [ ] RIP: 0010:sctp_chunk_hold+0xe/0x40 [sctp] [ ] Call Trace: [ ] [ ] sctp_sf_send_reconf+0x2c/0x100 [sctp] [ ] sctp_do_sm+0xa4/0x220 [sctp] [ ] sctp_generate_reconf_event+0xbd/0xe0 [sctp] [ ] call_timer_fn+0x26/0x130 This patch is to fix it by returning from the timer handler if asoc strreset_chunk is already set to NULL. Fixes: 7b9438de0cd4 ("sctp: add stream reconf timer") Reported-by: Ying Xu Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sctp/sm_sideeffect.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index b3815b568e8e..463c4a58d2c3 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c @@ -458,6 +458,10 @@ void sctp_generate_reconf_event(struct timer_list *t) goto out_unlock; } + /* This happens when the response arrives after the timer is triggered. */ + if (!asoc->strreset_chunk) + goto out_unlock; + error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT, SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_RECONF), asoc->state, asoc->ep, asoc, -- 2.35.1