!48 [sync] PR-46: libteamdctl: validate the bus name before using it.

From: @openeuler-sync-bot 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
This commit is contained in:
openeuler-ci-bot 2025-04-23 10:00:49 +00:00 committed by Gitee
commit 62d79babcc
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 66 additions and 1 deletions

View File

@ -0,0 +1,60 @@
From 3bbce8a171deab6cd3d7d57d128bc2dbaea451f0 Mon Sep 17 00:00:00 2001
From: Xin Long <lucien.xin@gmail.com>
Date: Fri, 15 Apr 2022 11:41:39 -0400
Subject: [PATCH] libteamdctl: validate the bus name before using it
Using bus name without validating it will cause core dump generated,
and it can be reproduced by:
# ip link add dummy0.1 type dummy
# teamdctl dummy0.1 state dump
This is normally a bug in some application using the D-Bus library.
D-Bus not built with -rdynamic so unable to print a backtrace
Aborted (core dumped)
Doing this many times can even create too many core files, customers
may complain about it.
This is triggered when calling cli_method_call("ConfigDump") in
cli_init(), so fix it by returning err in cli->init/cli_dbus_init()
if the bus name fails to validate.
Note this is safe, as with dbus, we can't use invalid dbus name to
create the team dev either.
Fixes: d8163e34c25c ("libteamdctl: do test method call instead or Introspect call")
Reported-by: Uday Patel <upatel@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
libteamdctl/cli_dbus.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libteamdctl/cli_dbus.c b/libteamdctl/cli_dbus.c
index dfef5c4..242ef86 100644
--- a/libteamdctl/cli_dbus.c
+++ b/libteamdctl/cli_dbus.c
@@ -183,12 +183,17 @@ static int cli_dbus_init(struct teamdctl *tdc, const char *team_name, void *priv
if (ret == -1)
return -errno;
+ err = -EINVAL;
dbus_error_init(&error);
+ if (!dbus_validate_bus_name(cli_dbus->service_name, &error)) {
+ err(tdc, "dbus: Could not validate bus name: %s - %s",
+ error.name, error.message);
+ goto free_service_name;
+ }
cli_dbus->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
if (!cli_dbus->conn) {
err(tdc, "dbus: Could not acquire the system bus: %s - %s",
error.name, error.message);
- err = -EINVAL;
goto free_service_name;
}
err = 0;
--
2.20.1

View File

@ -1,6 +1,6 @@
Name: libteam
Version: 1.31
Release: 4
Release: 5
Summary: User-space counterpart library for team network
License: LGPLv2+
URL: http://www.libteam.org
@ -8,6 +8,7 @@ Source: http://www.libteam.org/files/libteam-%{version}.tar.gz
Patch0: libteam-fix-error-options-in-doc.patch
Patch1: backport-revert-teamd-Disregard-current-state-when-considerin.patch
Patch2: backport-libteamdctl-validate-the-bus-name-before-using-it.patch
BuildRequires: gcc jansson-devel libdaemon-devel libnl3-devel
BuildRequires: swig dbus-devel systemd doxygen
@ -115,6 +116,10 @@ install -p -m 755 utils/bond2team $RPM_BUILD_ROOT%{_bindir}/bond2team
%{_mandir}/man8/teamnl.8*
%changelog
* Wed Apr 23 2025 Yu Peng <yupeng@kylinos.cn> - 1.31-5
- sync community patches:
backport-libteamdctl-validate-the-bus-name-before-using-it.patch
* Fri Nov 01 2024 xuguangmin <xuguangmin@kylinos.cn> - 1.31-4
- List non-existent files.