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 45DC1288530; Thu, 25 Jun 2026 13:10:08 +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=1782393009; cv=none; b=TSmBBD5tOqYB8esUKoDx+3nVJzNJeZcPiiWo3IclYhKg/SJZEG1zTaesWDLJEBlAmhZfVYUwHGmZoB8Z99UioSNf1giCz1RrXmavM/D4SdO2Pvy0tHS/cFtljAbkHc9Kkbkxo+W+EwXMKMSIPSIN+2gWDXLJC7NFAsVSjISPjcs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782393009; c=relaxed/simple; bh=sZBFq2+aHfYFsBRrj/vKSFIiCOS/alBZVEMbcHs1Eq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qyW0XqW5lriOsi97YvUjfSr7GRMe46KC0SHqpiUG2MsB+vDJBEHiFnfa3S9tKP99kCdra5kOMaTxyioBAl+2PVJJEOrae17vBD9H3zP/TCVSsTbdLkVSY+8pc2X/OaD47/xMXGX/9SIpn7YjVRPzNyVRWIW8eTLPf9kBxu8AEno= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=K+YfTW1n; 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="K+YfTW1n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B4341F000E9; Thu, 25 Jun 2026 13:10:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1782393008; bh=8TTZWnYuDabfy3qUr/4RS9wW2i7o0gkBuGJdAGrNRoc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=K+YfTW1n1SD4qMsgIwfIWCvsbrX1atD7pDaj07b0sAK7jyJfmzQsMEHa72q0gyOfW GDr3ZgJ1OkOFRbOSR5/vqmE/l4jhWcL1cHqzj4hZsQZWr+M5WzBxvGFZ48wp3ORbV0 0rXKt30r3Ke+TWYQ1E6LjokzY9MaVrV6IoqPCwyQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bernard Pidoux Subject: [PATCH 7.0 29/49] rose: clear neighbour pointer in rose_kill_by_device() Date: Thu, 25 Jun 2026 14:03:41 +0100 Message-ID: <20260625125641.606615670@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260625125637.527552689@linuxfoundation.org> References: <20260625125637.527552689@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 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bernard Pidoux commit 606e42d195b467480d4d405f8814c48d1651a76a upstream. rose_kill_by_device() drops the neighbour reference but leaves rose->neighbour pointing at it, unlike every other rose_neigh_put() site (see "rose: clear neighbour pointer after rose_neigh_put() in state machines"). The heartbeat STATE_0 reaping path then puts the same neighbour a second time, causing a rose_neigh refcount underflow and a use-after-free. Set rose->neighbour = NULL after the put, restoring the invariant. Signed-off-by: Bernard Pidoux Signed-off-by: Greg Kroah-Hartman --- net/rose/af_rose.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -216,8 +216,16 @@ start: * looping forever in ROSE_STATE_0 with no owner. */ sock_set_flag(sk, SOCK_DESTROY); - if (rose->neighbour) + if (rose->neighbour) { rose_neigh_put(rose->neighbour); + /* Clear the pointer after dropping the reference, as + * every other rose_neigh_put() site does. Otherwise + * rose_heartbeat_expiry() (STATE_0 reaping) sees a stale + * rose->neighbour and puts it a second time -> rose_neigh + * refcount underflow / use-after-free. + */ + rose->neighbour = NULL; + } netdev_put(rose->device, &rose->dev_tracker); rose->device = NULL; }