lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Mon, 24 Aug 2015 13:07:34 +0200
From:	David Herrmann <dh.herrmann@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	gregkh@...uxfoundation.org, Daniel Mack <daniel@...que.org>,
	tixxdz@...ndz.org, David Herrmann <dh.herrmann@...il.com>
Subject: [PATCH] kdbus/selftests: properly reset flags on re-use

If a test runs NAME_ACQUIRE multiple times, we really need to reset the
'flags' argument for each call. It's an in/out argument, so it might have
been changed by the kdbus_name_acquire() helper. We must not rely on the
flags to be unchanged, so reset them properly.

Signed-off-by: David Herrmann <dh.herrmann@...il.com>
---
 tools/testing/selftests/kdbus/test-activator.c | 5 ++++-
 tools/testing/selftests/kdbus/test-message.c   | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kdbus/test-activator.c b/tools/testing/selftests/kdbus/test-activator.c
index 3d1b763..c576a30 100644
--- a/tools/testing/selftests/kdbus/test-activator.c
+++ b/tools/testing/selftests/kdbus/test-activator.c
@@ -47,7 +47,7 @@ static int kdbus_priv_activator(struct kdbus_test_env *env)
 	int ret;
 	struct kdbus_msg *msg = NULL;
 	uint64_t cookie = 0xdeadbeef;
-	uint64_t flags = KDBUS_NAME_REPLACE_EXISTING;
+	uint64_t flags;
 	struct kdbus_conn *activator;
 	struct kdbus_conn *service;
 	struct kdbus_conn *client;
@@ -119,12 +119,14 @@ static int kdbus_priv_activator(struct kdbus_test_env *env)
 	/* Policies are still checked, access denied */
 
 	ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+		flags = KDBUS_NAME_REPLACE_EXISTING;
 		ret = kdbus_name_acquire(unpriv, "foo.priv.activator",
 					 &flags);
 		ASSERT_RETURN(ret == -EPERM);
 	}));
 	ASSERT_RETURN(ret >= 0);
 
+	flags = KDBUS_NAME_REPLACE_EXISTING;
 	ret = kdbus_name_acquire(service, "foo.priv.activator",
 				 &flags);
 	ASSERT_RETURN(ret == 0);
@@ -216,6 +218,7 @@ static int kdbus_priv_activator(struct kdbus_test_env *env)
 	ASSERT_RETURN(ret == 0);
 
 	ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+		flags = KDBUS_NAME_REPLACE_EXISTING;
 		ret = kdbus_name_acquire(unpriv, "foo.priv.activator",
 					 &flags);
 		ASSERT_RETURN(ret == -EPERM);
diff --git a/tools/testing/selftests/kdbus/test-message.c b/tools/testing/selftests/kdbus/test-message.c
index 563dc85..33d349b 100644
--- a/tools/testing/selftests/kdbus/test-message.c
+++ b/tools/testing/selftests/kdbus/test-message.c
@@ -293,7 +293,7 @@ static int kdbus_test_activator_quota(struct kdbus_test_env *env)
 	struct kdbus_conn *sender;
 	struct kdbus_conn *activator;
 	struct kdbus_msg *msg;
-	uint64_t flags = KDBUS_NAME_REPLACE_EXISTING;
+	uint64_t flags;
 	struct kdbus_cmd_recv recv = { .size = sizeof(recv) };
 	struct kdbus_policy_access access = {
 		.type = KDBUS_POLICY_ACCESS_USER,
@@ -375,6 +375,7 @@ static int kdbus_test_activator_quota(struct kdbus_test_env *env)
 	kdbus_msg_free(msg);
 
 	/* Try to acquire the name now */
+	flags = KDBUS_NAME_REPLACE_EXISTING;
 	ret = kdbus_name_acquire(conn, "foo.test.activator", &flags);
 	ASSERT_RETURN(ret == 0);
 
@@ -431,6 +432,7 @@ static int kdbus_test_activator_quota(struct kdbus_test_env *env)
 	ASSERT_RETURN(ret == -ENOBUFS);
 
 	/* Acquire the name again */
+	flags = KDBUS_NAME_REPLACE_EXISTING;
 	ret = kdbus_name_acquire(conn, "foo.test.activator", &flags);
 	ASSERT_RETURN(ret == 0);
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ