From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 485FA4F93D0; Wed, 30 Sep 2026 16:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790784950; cv=none; b=a2ocvKxROuknf5RmqTi6udg2goAlyOGcR/g/i/qrXynIYbJU0XbRDPmiXXl/uYFfJQlBfQnL7uwObZ+qxSvCaX+4QFvPxkB1MeMwj969RUNKNU/6+BxC6sRRdo2PtLCsVtNR06BcveiX5ng5nLwbSk9EBBNJHRpeAQqoUkzsQNU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790784950; c=relaxed/simple; bh=94WkzZF9vtO69Qnqd8ouwn6DcQjJ4eAHTTndHZvXtBU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BqtblxseD2YAuPtz0Fv/2jTo4pFSg7YcSpjans8UAuY4S3C+j6VX12ZF+4jlVkBlngG2SPmj9a97ifDQHJWUhd0WiaIQ68eQyNxc+k3MlBQBB9GBSUfAlJ4YZMvo7uCJBLdJsu9VSivNSCPCSigTiPUoJ38342GY8DDB1O/bGjk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=f8gpEkYf; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="f8gpEkYf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFB1C1F000FF; Wed, 30 Sep 2026 16:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790784946; bh=fg5Z06/CCjohb1pNanKhbON0nQ44qO6JGE6esx+Tg70=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f8gpEkYf9/mYckddkaII1PZrIJZrwnfrKq7bqGHWQV6noFEILKXiw7dOCrAZuHRiD gIF7ikE4hf+Erpky/8xF7eHDjTHK8Sj987LjcslS5+TJLSS2GusHak6qegB8uQ25z3 4qr3JRSnRo3pc4yGyFaWeCuWrqr/0P+xADtK64gE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zero Day Initiative , Xin Long , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 334/982] sctp: fix a TOCTOU race in SCTP_CMD_TIMER_START Date: Wed, 30 Sep 2026 17:17:50 +0200 Message-ID: <20260930152423.993785233@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xin Long [ Upstream commit 2188569e7e1b0bc3f3b557dc97ab7a02befc11c8 ] The SCTP_CMD_TIMER_START handler checks timer_pending() before calling timer_reduce(). The timer can expire and detach between these operations, causing timer_reduce() to rearm the timer without taking the association reference required for the newly armed timer. The timer callback later unconditionally drops its association reference, which can leave the association reference count unbalanced and result in use-after-free during association teardown. Use the return value of timer_reduce() to determine whether the timer was actually armed. Take the association reference only when timer_reduce() successfully starts a new timer, closing the race between checking the timer state and rearming it. This issue was reported by Nico Yip (@_cyeaa_) working with TrendAI Zero Day Initiative. Fixes: 20a785aa52c8 ("sctp: Don't add the shutdown timer if its already been added") Reported-by: Zero Day Initiative Signed-off-by: Xin Long Link: https://patch.msgid.link/9d8f1b5c50329d5ea7c642128d35681abaa9ed20.1787773744.git.lucien.xin@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sctp/sm_sideeffect.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index 6989798a83c8c..4391f070dc1e1 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c @@ -1540,17 +1540,8 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type, timeout = asoc->timeouts[cmd->obj.to]; BUG_ON(!timeout); - /* - * SCTP has a hard time with timer starts. Because we process - * timer starts as side effects, it can be hard to tell if we - * have already started a timer or not, which leads to BUG - * halts when we call add_timer. So here, instead of just starting - * a timer, if the timer is already started, and just mod - * the timer with the shorter of the two expiration times - */ - if (!timer_pending(timer)) + if (!timer_reduce(timer, jiffies + timeout)) sctp_association_hold(asoc); - timer_reduce(timer, jiffies + timeout); break; case SCTP_CMD_TIMER_RESTART: -- 2.53.0