From e8e31c561a43ae97759e2279b2ff5856d9ee50fb Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Fri, 10 Jan 2025 11:23:33 +0900 Subject: [PATCH] kdbus: Replace the code that reads the attr with check code Replace the code that directly accesses and read /proc/self/attr/current with check code to /sys/fs/smackfs. This is because, direct accessing and reading to /proc/self/attr/current is invalid when SMACK is disabled. Change-Id: I4d74377c0e7cd0d55e8720e692e49bb36c3ecd6e Signed-off-by: Unsung Lee --- packaging/linux-tizen-modules-source.spec | 2 +- tests/kdbus/kdbus-util.c | 26 +++-------------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/packaging/linux-tizen-modules-source.spec b/packaging/linux-tizen-modules-source.spec index b6a7d87..6a0ba7b 100644 --- a/packaging/linux-tizen-modules-source.spec +++ b/packaging/linux-tizen-modules-source.spec @@ -1,5 +1,5 @@ Name: linux-tizen-modules-source -Version: 7.5.0 +Version: 7.5.1 Release: 0 License: GPL-2.0+ Source0: %{name}-%{version}.tar.xz diff --git a/tests/kdbus/kdbus-util.c b/tests/kdbus/kdbus-util.c index d9fa167..6dae7ae 100644 --- a/tests/kdbus/kdbus-util.c +++ b/tests/kdbus/kdbus-util.c @@ -1825,29 +1825,9 @@ wur int config_cgroups_is_enabled(void) wur int config_security_is_enabled(void) { - int fd; - int ret; - char buf[128]; - - /* CONFIG_SECURITY is disabled */ - if (access("/proc/self/attr/current", F_OK) != 0) + /* When SMACK is disabled this directory does not exist */ + if (access("/sys/fs/smackfs", F_OK) != 0) return 0; - /* - * Now only if read() fails with -EINVAL then we assume - * that SECLABEL and LSM are disabled - */ - fd = open("/proc/self/attr/current", O_RDONLY|O_CLOEXEC); - if (fd < 0) - return 1; - - ret = read(fd, buf, sizeof(buf)); - if (ret == -1 && errno == EINVAL) - ret = 0; - else - ret = 1; - - CLOSE(fd); - - return ret; + return 1; } -- 2.34.1