public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Sven Schnelle <svens@linux.ibm.com>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] mmap01: initialize buffer in check_file()
Date: Wed, 22 Jan 2025 13:33:33 +0100	[thread overview]
Message-ID: <yt9d5xm76naa.fsf@linux.ibm.com> (raw)
In-Reply-To: <Z5DkUNyjq9x-jY7v@yuki.lan> (Cyril Hrubis's message of "Wed, 22 Jan 2025 13:28:00 +0100")

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> >> > mmap01 reported random test failures. Turns out the
>> >> > the temporary buffer in check_file() isn't initialized.
>> >> > The SAFE_READ reads less then sizeof(buf) bytes so the
>> >> > rest stays initialized and might contain bytes check_file()
>> >> > is looking for.
>> >> 
>> >> Looks reasonable to me.
>> >> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>> >> 
>> >> @Cyril a candidate for merge before the release.
>> >
>> > Alternatively we could use the return value from the SAFE_READ() instead
>> > of the buf_len. Also I suppose that we could check that we read at least
>> > something.
>> 
>> I wonder whether a check that strlen(STRING) bytes was read is
>> sufficient, and if it's more just FAIL the test? My understanding of the
>> test is that the data written beyond file's end isn't yet synced, so
>> if we can read more bytes that would already be an error?
>
> I would say yes, but it does not hurt to keep the check that the file
> data were not corrupted by the write after the file end. So maybe we
> just need to:
>
> 1. check that we read right size
> 2. check that the buffer has correct bytes

Ok. I'll change the patch and send a V2 later.

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

  reply	other threads:[~2025-01-22 12:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-22 10:09 [LTP] [PATCH] mmap01: initialize buffer in check_file() Sven Schnelle
2025-01-22 10:26 ` Petr Vorel
2025-01-22 11:01   ` Cyril Hrubis
2025-01-22 12:13     ` Sven Schnelle
2025-01-22 12:28       ` Cyril Hrubis
2025-01-22 12:33         ` Sven Schnelle [this message]
2025-01-22 10:43 ` Ricardo B. Marliere via ltp

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=yt9d5xm76naa.fsf@linux.ibm.com \
    --to=svens@linux.ibm.com \
    --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