public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@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:39:36 +0200	[thread overview]
Message-ID: <20240524113936.GA114626@pevik> (raw)
In-Reply-To: <ZlB6-BvuMMVfhr_t@yuki>

> 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:

Sounds reasonable, I'll check it. But now I'm going to tag 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;
Very nit: tst_res(TFAIL and *stop and *fail assignments could be in some macro
(e.g. QUIT(msg, ...) ).

Kind regards,
Petr
> +               }
> +
>                 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,

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-05-24 11:40 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
2024-05-24 11:39     ` Petr Vorel [this message]
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=20240524113936.GA114626@pevik \
    --to=pvorel@suse.cz \
    --cc=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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