From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 394691E87B; Mon, 23 Jun 2025 22:06:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750716402; cv=none; b=C9L15rbZ3rHpnBOOfwO7njE36KiGATYSSUCBA763QViYB2Utd7GtSPjU9ab45jmSWWBdrQ7G7CKMK+LtnXruuFNHYhgjubq1S+eYqFJt1V2iqXhB7A9IZUBIMUjd8DHoN3mmqmYqFM+/2ZUtVql670XqCNP4a7QnTQdQNbF7PY4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750716402; c=relaxed/simple; bh=9Vb9xjfiFPyFveMo7/Kv9ODAqA2fYhMwjWg3T/+HPA0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lckSBnxEkMuu+UzU+MZ6lFGwYOQxjP6CRZwv7z+nMY3GdkoVB3+8OSAGM8op7vIYEKbLmeH/wQCvHg6XLqFr007skLZDROQUIKeAxkE4+Ow9ADq/+8PonS+47Eo73HW8nXEsx9UFcboL4LCJy1dut2mPlete1IlinVqZGhApNzI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jFHeqFZs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jFHeqFZs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C565AC4CEEA; Mon, 23 Jun 2025 22:06:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750716402; bh=9Vb9xjfiFPyFveMo7/Kv9ODAqA2fYhMwjWg3T/+HPA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFHeqFZs5mL3/CS1W/VZNKju5OCHNee47NDrT+ZMObFTPESsvhoM7xkA2HfxZNVKZ /UtzhMXwAgvajG0Yp5QL9pIjoQQMvX5THRRqQR0v4bhD/NzvPtMxPGtrXJrmBbddxs 4CnVRZDciv4hkiiyNB8EXrWbGUiZxesY+dm97dj0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haixia Qu , Tung Nguyen , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 261/290] tipc: fix null-ptr-deref when acquiring remote ip of ethernet bearer Date: Mon, 23 Jun 2025 15:08:42 +0200 Message-ID: <20250623130634.762651370@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130626.910356556@linuxfoundation.org> References: <20250623130626.910356556@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haixia Qu [ Upstream commit f82727adcf2992822e12198792af450a76ebd5ef ] The reproduction steps: 1. create a tun interface 2. enable l2 bearer 3. TIPC_NL_UDP_GET_REMOTEIP with media name set to tun tipc: Started in network mode tipc: Node identity 8af312d38a21, cluster identity 4711 tipc: Enabled bearer , priority 1 Oops: general protection fault KASAN: null-ptr-deref in range CPU: 1 UID: 1000 PID: 559 Comm: poc Not tainted 6.16.0-rc1+ #117 PREEMPT Hardware name: QEMU Ubuntu 24.04 PC RIP: 0010:tipc_udp_nl_dump_remoteip+0x4a4/0x8f0 the ub was in fact a struct dev. when bid != 0 && skip_cnt != 0, bearer_list[bid] may be NULL or other media when other thread changes it. fix this by checking media_id. Fixes: 832629ca5c313 ("tipc: add UDP remoteip dump to netlink API") Signed-off-by: Haixia Qu Reviewed-by: Tung Nguyen Link: https://patch.msgid.link/20250617055624.2680-1-hxqu@hillstonenet.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/tipc/udp_media.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index b16ca400ff559..e993bd6ed7c26 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c @@ -489,7 +489,7 @@ int tipc_udp_nl_dump_remoteip(struct sk_buff *skb, struct netlink_callback *cb) rtnl_lock(); b = tipc_bearer_find(net, bname); - if (!b) { + if (!b || b->bcast_addr.media_id != TIPC_MEDIA_TYPE_UDP) { rtnl_unlock(); return -EINVAL; } @@ -500,7 +500,7 @@ int tipc_udp_nl_dump_remoteip(struct sk_buff *skb, struct netlink_callback *cb) rtnl_lock(); b = rtnl_dereference(tn->bearer_list[bid]); - if (!b) { + if (!b || b->bcast_addr.media_id != TIPC_MEDIA_TYPE_UDP) { rtnl_unlock(); return -EINVAL; } -- 2.39.5