mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: gregkh@linuxfoundation.org, Daniel Mack <daniel@zonque.org>,
	tixxdz@opendz.org, David Herrmann <dh.herrmann@gmail.com>
Subject: [PATCH] kdbus/selftests: properly reset flags on re-use
Date: Mon, 24 Aug 2015 13:07:34 +0200	[thread overview]
Message-ID: <1440414454-1669-1-git-send-email-dh.herrmann@gmail.com> (raw)

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


                 reply	other threads:[~2015-08-24 11:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440414454-1669-1-git-send-email-dh.herrmann@gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=daniel@zonque.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tixxdz@opendz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®