From: Cyril Hrubis <chrubis@suse.cz>
To: Martin Cermak <mcermak@redhat.com>
Cc: valgrind-developers@lists.sourceforge.net, ltp@lists.linux.it
Subject: Re: [LTP] Avoid syscall param ioctl(generic) points to uninitialised byte(s)
Date: Thu, 16 Apr 2026 12:07:18 +0200 [thread overview]
Message-ID: <aeC01nkaA2jzhUVV@yuki.lan> (raw)
In-Reply-To: <20260416092131.kkbfd3cdi3tv7z7l@lida.tpb.lab.eng.brq.redhat.com>
Hi!
> > > diff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd01.c b/testcases/kernel/syscalls/userfaultfd/userfaultfd01.c
> > > index 7368d3863..d24766e7c 100644
> > > --- a/testcases/kernel/syscalls/userfaultfd/userfaultfd01.c
> > > +++ b/testcases/kernel/syscalls/userfaultfd/userfaultfd01.c
> > > @@ -92,8 +92,8 @@ static void *handle_thread(void)
> > > static void run(unsigned int i)
> > > {
> > > pthread_t thr;
> > > - struct uffdio_api uffdio_api = {};
> > > - struct uffdio_register uffdio_register;
> > > + struct uffdio_api uffdio_api = {0, };
> > > + struct uffdio_register uffdio_register = {0, };
> >
> > Given that we were using = {}; in the code before can we keep using that
> > and for all instances?
>
> I saw both initializers in the LTP source, see `$ grep -rIn '= {};'` and
> `$ grep -rIn '= { 0, };'`. The latter one is compliant with older standards.
> But to keep the coding style within this file, I've updated the initializer.
>
> > Also I assume the problem is the ioctls field in the uffdio_api
> > structure that is not initialized beacuse is supposed to be set by
> > kernel before returning into userspace. Should valgrind warn about such
> > cases?
>
> You are right that zeroing just this uffdio_register.ioctls = 0; is suffi-
> cient to to avoid the valgrind complaint. Zeroing whole the struct seems
> syntactically more concise and also correct.
That's not what I was trying to point out. Some fields of structures
passed to ioctls are output-only. The question is if valgrind should
warn if we do not set output only field in such structure?
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-04-16 10:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 11:47 [LTP] Avoid syscall param ioctl(generic) points to uninitialised byte(s) Martin Cermak via ltp
2026-04-14 12:44 ` linuxtestproject.agent
2026-04-15 10:18 ` Cyril Hrubis
2026-04-16 9:21 ` Martin Cermak via ltp
2026-04-16 10:07 ` Cyril Hrubis [this message]
2026-04-16 12:39 ` Martin Cermak 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=aeC01nkaA2jzhUVV@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=mcermak@redhat.com \
--cc=valgrind-developers@lists.sourceforge.net \
/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