* [PATCH] kdbus/selftests: properly reset flags on re-use
@ 2015-08-24 11:07 David Herrmann
0 siblings, 0 replies; only message in thread
From: David Herrmann @ 2015-08-24 11:07 UTC (permalink / raw)
To: linux-kernel; +Cc: gregkh, Daniel Mack, tixxdz, David Herrmann
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@gmail.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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-08-24 11:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-24 11:07 [PATCH] kdbus/selftests: properly reset flags on re-use David Herrmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®