Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1770894iob; Thu, 5 May 2022 07:57:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiCdPXq8u648ZzjK6csh6l6pIXXhtgvPi4VSiF7QYi2Cv3VvtdlDwu0FZzIm0ewUxBIh07 X-Received: by 2002:a17:903:40c3:b0:15e:9d4a:5d24 with SMTP id t3-20020a17090340c300b0015e9d4a5d24mr22781320pld.77.1651762662258; Thu, 05 May 2022 07:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651762662; cv=none; d=google.com; s=arc-20160816; b=PaHFE+8IIPh5agiUdnvC62s4CIn+AfLNNYPhH6bj9q96xIBR4oS816XL8rCJCSEX0g u71u1uMFobru486NMXkz9Ptyl7y+fF6CW2zNABkaQcwgIGgXT+8z4Rb4bXj+1aRzwI1d 0quJ7Vtsun3x1X8HEem2CcgQ5xLGp4MIZyikTdWY/6EIM6XdpfahRVeSXXmp2KQGY4br xYIJidcPPZrtPLmTWsa5cXtely3DtRdZlmdaV+kuDTsQ43K8HOf+jxoEwuF0jGd4tU5M bt7DuOh+dC6lqQYlNppOzW3jt8d16DHJ2iVW+lI8M1eT5Pb1r2qveKHZmUvidhiN+3sg ktfQ== 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=6JtTNCwqJqZBLDmOeOe+4AnkOGJwfloiuaWJ8l91tgM=; b=okFP0NRljOpCjHX+VigwSq1TgkbEeZOQ+AiAqK4ZePTTA65jVQvETXtZ0d+ugv+ssV V4layE4GDBeZdGYiukDp4JVyPZPfIds0G9Tgp3Mn1KvXEwX5Wb+rvcUcQFjA3QBziEbD 6Phn233oa9w1WCGSTAnztd8xPl6nkc6THvZcD7nXC/TeemuAHcJtcRavZb02HDrvaoRD 6TSmKPkED8oSNyf8eB2pNyjzPzSiDl7MSL509YenfU0Nlbih39rVqi2lNgce1KUpC+e4 o6vqLjEHoU53fbv55vIx9mgGOe7BFLCPsCIfamZDpWB53LGM7tBSmgpUdNuGNGiFvSDr +i+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=I8QO7a34; 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 x187-20020a6331c4000000b003c20594afcdsi1836575pgx.755.2022.05.05.07.57.24; Thu, 05 May 2022 07:57:42 -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=I8QO7a34; 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 S1354261AbiEDQzX (ORCPT + 99 others); Wed, 4 May 2022 12:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354117AbiEDQxv (ORCPT ); Wed, 4 May 2022 12:53:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F05844831E; Wed, 4 May 2022 09:49:06 -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 4A94761775; Wed, 4 May 2022 16:49:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96FA3C385AA; Wed, 4 May 2022 16:49:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651682945; bh=gjcUHRuosnRAQAIEo2at6PXscj2jLOjPPqadUR14v30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I8QO7a34nRpgqQh8ub3OeqSa8HzP2eNZwt3fRF0NIYBIqsLMLkcESw2VN4zxHQiXp pBYTl90Iyrv4/7KEpDUtwG95y1L+9QnvQfyIDJ59+yymIawKJsXYH37E2ln69al/w/ +N89u+i1uDCkgv/GoF8Ouzxg8nHPq9pJR/JytlJE= 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.4 50/84] sctp: check asoc strreset_chunk in sctp_generate_reconf_event Date: Wed, 4 May 2022 18:44:31 +0200 Message-Id: <20220504152931.303190399@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504152927.744120418@linuxfoundation.org> References: <20220504152927.744120418@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 0d225f891b61..8d32229199b9 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