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 39A883B6364; Thu, 17 Sep 2026 17:13:15 +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=1789665197; cv=none; b=pPTbBwAAJ600nWyXtkypK3KeIx/5SIgOeGRIe1kNHqTVZnAtsZ2zFFDoMZw9kr7YtNVdA/lxndRRNwzaNOF07sJHFkVQCSGWVsfQwLzPBgfyX3uAC23ZfRnJ2Z4gjXjwy+HpUALiqUbNqTW61DS/aickVTia7N5hzAbqeI62mt0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789665197; c=relaxed/simple; bh=mcdM4fPOvdPdWzmwnUPSvToQXUK6WYnhEK1XplmnY4M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NzxjpYl92wMM6OOAflyXWEzclsQwWNn5D57/lINsfxChMV/aF6z+S2rDjAQL0jzfvcwdW0VP73P5v8o/HnMaQhxOWRghgBw7jpjKjIReVQdLyo6X9SSqapnBWeL8LVwG4/XR9DLzA77dpMvHJHOVlW7fQE+2A6StWurk9LXIlPU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lVmOxuIG; 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="lVmOxuIG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D1271F000FF; Thu, 17 Sep 2026 17:13:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789665195; bh=OfqihVRFKH1ChSnl1WSUjUeWgtOr8OXcEaoGjJuu/rY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lVmOxuIGg4fDlh+Ten8VXe0RVnu3hY+00iJsxrMb/kOcmYBjm5j4UDlU/KV1IaLMO vX9xrnLmYD0U7OyBCPBifS4h6X6fbHVFIc9nz3w+E+UuTxA6PA7svh83V0782Nlvfm 6FN0ti3W57c3ooxw8udl8U2Z0vFLR14PDkJM/oiI= 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.18 0624/1250] sctp: fix a TOCTOU race in SCTP_CMD_TIMER_START Date: Thu, 17 Sep 2026 16:06:59 +0100 Message-ID: <20260917151608.792576182@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151551.901433442@linuxfoundation.org> References: <20260917151551.901433442@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.18-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 94716406d602c..0d99b7e8c082f 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c @@ -1545,17 +1545,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