Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2455707iob; Fri, 6 May 2022 03:22:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYl+tvQkjMc5VmeFumMUfn6JclohQUMrn4+kj9xZ1pnNVRozijriVBsEmKrgt8SLO8FSf+ X-Received: by 2002:a17:906:a453:b0:6f5:132c:1a10 with SMTP id cb19-20020a170906a45300b006f5132c1a10mr2293245ejb.746.1651832569160; Fri, 06 May 2022 03:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651832569; cv=none; d=google.com; s=arc-20160816; b=kLLdSsEBzgsrFXrNauR2PEjG/cpX0TG40Fpg15+iBw57FDQrx90itpRPEgJ/R1XVZF PjIsmSz+dUMEKnKyhwuMyjDLCliGrlsGc0+GhOS9o/2A8DvAXYjl8viu+jKWs9P+g5I7 jV2SpXcdJdTTUUZ8svlK7Jz/idtK6QiYQPCPMH89RcUrTtRzc+1OWsTtXMKYVo9qIuEW G6+sXM18jzC2Ocfwv57sugmTrrEZGYwz9pQbcGC3JW6b8CpFz0dfLJ4Wvei/6eTOpflG xK6MOCji2DENlQ3Y5T4A/8MvyMs3ERlLbmVZC463lofxLxC2eSWLR4mDU+5jn8Z5wUBI Qs4Q== 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=Nj0Xv1wpetMUJlsg0Zj793pu8eYyrT9UbUef5fDxd8jRSoJxwBT+CpJ+rO4c/xZwRS amEh3mitirWGPTgDtBAFYxoXAkYvxyqwfYEdpnyWxMC5llqscXQhplE13ZLgI12RlR9z wYsbmlQ7hE0+f7Vi+Azo9irQuqUbFagCF7D5miASUGWdCNpMbGvmP7VvzVMO2gcxn6SD BzBV1v3GxUTNPrlHpfu6MMmxaJs7EwHTfBRm75iBKbZ2zMeBFHCSRd0grgJm7L8tCSTf BLRq8KYBK3m2APUBzfMbqWSqyEu0YaFxMZUfA0eJ9rGn7Q31gAE6VIH5YG+Q503XO9vW bslQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1HIluVmq; 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 w18-20020a50f112000000b00420c32eec37si3909671edl.119.2022.05.06.03.22.24; Fri, 06 May 2022 03:22:49 -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=1HIluVmq; 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 S1356709AbiEDRSy (ORCPT + 99 others); Wed, 4 May 2022 13:18:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356167AbiEDRE4 (ORCPT ); Wed, 4 May 2022 13:04:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6809506E7; Wed, 4 May 2022 09:53:56 -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 1AB07617DE; Wed, 4 May 2022 16:53:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64C55C385B2; Wed, 4 May 2022 16:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683235; bh=e+oxjEJlR1PMHd11JKjXVmZGlgC98O91GpA6vAZb0A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1HIluVmqrrgo6YlZfb9epWyIdSSbbDhAtyw0VK5scyhwp4OKRGs2boiPywkwzot79 MnXz3rfKAc9BivRqvJDEq9hQ8SRg9GufRJDWfXaVHHdZoFvXuPYtLr4eSkCpp9Isli 4CCdYrc1oM29JqEGlwZYklKjLh9stID4SAr4LT/M= 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.15 088/177] sctp: check asoc strreset_chunk in sctp_generate_reconf_event Date: Wed, 4 May 2022 18:44:41 +0200 Message-Id: <20220504153100.975775798@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=-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