public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH liburing 1/4] tests/reg-wait: test registering RO memory
Date: Wed, 20 Nov 2024 23:39:48 +0000	[thread overview]
Message-ID: <206a368e30ce838626ee998cecbe39e1d15af0f9.1731987026.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Mapping should be writable and those we can't use read only user memory,
check that it fails. It also exercises one of the fail paths.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 test/reg-wait.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/test/reg-wait.c b/test/reg-wait.c
index b7c823a..544cd48 100644
--- a/test/reg-wait.c
+++ b/test/reg-wait.c
@@ -365,8 +365,22 @@ static int test_regions(void)
 		return T_EXIT_FAIL;
 	}
 	rd.user_addr = (__u64)(unsigned long)buffer;
-
 	free(buffer);
+
+	buffer = mmap(NULL, page_size, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+	if (buffer == MAP_FAILED) {
+		fprintf(stderr, "mmap alloc failed\n");
+		return 1;
+	}
+
+	rd.user_addr = (__u64)(unsigned long)buffer;
+	ret = test_try_register_region(&mr, true);
+	if (ret != -EFAULT) {
+		fprintf(stderr, "test_try_register_region() RO uptr %i\n", ret);
+		return T_EXIT_FAIL;
+	}
+
+	munmap(buffer, page_size);
 	return 0;
 }
 
-- 
2.46.0


  reply	other threads:[~2024-11-20 23:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-20 23:39 [PATCH liburing 0/4] test kernel allocated regions Pavel Begunkov
2024-11-20 23:39 ` Pavel Begunkov [this message]
2024-11-20 23:39 ` [PATCH liburing 2/4] test/reg-wait: basic test + probing of kernel regions Pavel Begunkov
2024-11-20 23:39 ` [PATCH liburing 3/4] test/reg-wait: add allocation abstraction Pavel Begunkov
2024-11-20 23:39 ` [PATCH liburing 4/4] test/reg-wait: test kernel allocated regions Pavel Begunkov

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=206a368e30ce838626ee998cecbe39e1d15af0f9.1731987026.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    /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