From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/openat2: New tests
Date: Mon, 2 Mar 2020 10:36:22 +0100 [thread overview]
Message-ID: <20200302093622.GA5288@rei.lan> (raw)
In-Reply-To: <20200302090718.hmyxgbmrwltxiz56@vireshk-i7>
Hi!
> > Hmm, I guess that it makes sense to add the pointer to how to the tcase
> > structure and allocate exact size for the E2BIG case. That should work
> > fine, right?
>
> We need to hack it a bit more to initialize rest of the memory as
> well. This is what I did before I dropped the idea.
Looking at the kernel the code that we are trying to trigger is
copy_struct_from_user() in include/linux/uacess.h. And indeed the area
after the kernel how structure has to be non-zero in order for the
structure to be deemed incompatible.
I guess that the easier way how to test this would be:
* Create an extended how structure
* Set bytes at the end of the extended structure to non-zero
The code you had there in the first place was passing by accident
because the were non-zero bytes on the stack after the structure, which
is pretty bad, because if it started to fail randomly nobody would know
why.
I guess that it would make sense to put this in a separate test and test
that everthing works fine as long as padd is zero and that we got a
failure with padd != 0.
So something as:
struct how_ext {
uint64_t flags;
uint64_t mode;
uint64_t resolve;
char padd[20];
};
Then setup the flags, mode and resolve and do two calls to openat2() one
with padd 0 => should work and one with pad != 0 should fail.
Does that sound reasonable?
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2020-03-02 9:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-28 10:50 [LTP] [PATCH] syscalls/openat2: New tests Viresh Kumar
2020-02-28 13:22 ` Cyril Hrubis
2020-03-02 6:37 ` Viresh Kumar
2020-03-02 7:31 ` Petr Vorel
2020-03-02 8:46 ` Cyril Hrubis
2020-03-02 9:07 ` Viresh Kumar
2020-03-02 9:36 ` Cyril Hrubis [this message]
2020-03-02 10:02 ` Viresh Kumar
2020-03-02 10:16 ` Cyril Hrubis
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=20200302093622.GA5288@rei.lan \
--to=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