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 5834B2940B; Mon, 23 Jun 2025 22:10: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=1750716642; cv=none; b=hd/U981YQjsHHQUPmFZW/fgNRP/ERLzn/LUyOqQlfvwMakchquloJGk63SRabuWajhzFLYma1b9Fd+w6XDDUSxQuK2fxdsYtHajLvTJGhVtkVr+2DBV+KMW+89Xw5rf6P3nx0I+B4Khk6vKDt2m7MUQB9eGDvc4Bh/A7RWdNvjQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750716642; c=relaxed/simple; bh=S/rIDpfKbyCZ/SmE1jDmpgm7WnpCVyZD02SKvExXqFg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nT0GO1vPmxRVEZBnnjhgZpwE1/VuUgxAqsdHKGpgLdR+pt0KTBo2X/EEgVWbSa5OBUdbgvkKhLtm+EoZ86mFFf5wz/H22JGNmxla3pL+ugqEfFB0bFkcc+4gmJ7OVgcYBdRlwjtrjYXiA7588MdUtRKFAi4LnKJCKRg4t9EI0OI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WMSXPrct; 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="WMSXPrct" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4CF9C4CEEA; Mon, 23 Jun 2025 22:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750716642; bh=S/rIDpfKbyCZ/SmE1jDmpgm7WnpCVyZD02SKvExXqFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WMSXPrctTdIt7GRLb0YfmqNyrVoWrMq42TmsiybRrBA3mWj3wVELY0KEkXBRIvL7C DrdyeWYE8Qq11fcldSX0jA0hMMaerj8p7YE+R4RU330T8Jcvw9Kp9huRAeuKmLmXWw 86TyXMUN5EFyoI7ZPFMIS7JhyC2zfedCIPdisrdQ= 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.15 544/592] tipc: fix null-ptr-deref when acquiring remote ip of ethernet bearer Date: Mon, 23 Jun 2025 15:08:22 +0200 Message-ID: <20250623130713.379387760@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130700.210182694@linuxfoundation.org> References: <20250623130700.210182694@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.15-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 108a4cc2e0010..258d6aa4f21ae 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