From: Cyril Hrubis <chrubis@suse.cz>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] syscalls/msgstress01: Fix off by one in array access
Date: Fri, 24 May 2024 13:33:12 +0200 [thread overview]
Message-ID: <ZlB6-BvuMMVfhr_t@yuki> (raw)
In-Reply-To: <233cf26a-3b1a-47db-90a4-764a95601699@suse.cz>
Hi!
> I'd at least add a check that size == data.len + 1.
Which is not true actually because we always send a 100 bytes of data
regardless the message size, which is probably another oversight.
So let's keep the test as it is for now and I will do more work on it
after the release.
To fix this we would have to do at least, but I do not want to change
the test at this point just before the release:
diff --git a/testcases/kernel/syscalls/ipc/msgstress/msgstress01.c b/testcases/kernel/syscalls/ipc/msgstress/msgstress01.c
index b6a64cf4f..f0da595cd 100644
--- a/testcases/kernel/syscalls/ipc/msgstress/msgstress01.c
+++ b/testcases/kernel/syscalls/ipc/msgstress/msgstress01.c
@@ -109,7 +109,7 @@ static void writer(const int id, const int pos)
int iter = num_iterations;
while (--iter >= 0 && !(*stop)) {
- int size = msgsnd(id, &buff->msg, 100, IPC_NOWAIT);
+ int size = msgsnd(id, &buff->msg, buff->msg.data.len + 1, IPC_NOWAIT);
if (size < 0) {
if (errno == EAGAIN) {
@@ -160,6 +160,15 @@ static void reader(const int id, const int pos)
return;
}
+ if (msg_recv.data.len + 1 != size) {
+ tst_res(TFAIL,
+ "Wrong message size have %i expected %i",
+ size, msg_recv.data.len+1);
+ *stop = 1;
+ *fail = 1;
+ return;
+ }
+
for (int i = 0; i < msg_recv.data.len; i++) {
if (msg_recv.data.pbytes[i] != buff->msg.data.pbytes[i]) {
tst_res(TFAIL, "Received wrong data at index %d: %x != %x", i,
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-05-24 11:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 15:59 [LTP] [PATCH] syscalls/msgstress01: Fix off by one in array access Cyril Hrubis
2024-05-23 16:08 ` Martin Doucha
2024-05-23 16:27 ` Petr Vorel
2024-05-24 11:33 ` Cyril Hrubis [this message]
2024-05-24 11:39 ` Petr Vorel
2024-05-24 11:43 ` Martin Doucha
2024-05-24 11:59 ` Cyril Hrubis
2024-05-24 12:01 ` Martin Doucha
2024-05-23 16:19 ` Petr Vorel
2024-05-23 18:35 ` Cyril Hrubis
2024-05-23 16:25 ` Petr Vorel
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=ZlB6-BvuMMVfhr_t@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=mdoucha@suse.cz \
/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