diff options
author | Guillem Jover <guillem@hadrons.org> | 2019-08-14 04:42:42 +0200 |
---|---|---|
committer | Jeff Moyer <jmoyer@redhat.com> | 2019-08-14 08:22:18 -0400 |
commit | 711c0381798c85f3e25ea0ab503b24857850a762 (patch) | |
tree | fc235230eb0ffb5e3feb1558a0c8a8047d143285 | |
parent | d7f5065448efb49b2a26e728ff735e12ea05b62e (diff) | |
download | libaio-711c0381798c85f3e25ea0ab503b24857850a762.tar.gz |
harness: Fix PROT_WRITE mmap check
This partially reverts commit d7f5065448efb49b2a26e728ff735e12ea05b62e.
The actual problem in the original code was that read() was being used
to assert whether the buffer was readable, but the kernel was instead
reading from the file descriptor and then writing into the buffer, so
no EFAULT was being generated (on architectures that do so).
We needed to use a write() so that the kernel would read from the
buffer.
Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
-rw-r--r-- | harness/cases/5.t | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/harness/cases/5.t b/harness/cases/5.t index 7d67562..b0a7c56 100644 --- a/harness/cases/5.t +++ b/harness/cases/5.t @@ -41,13 +41,12 @@ int test_main(void) assert(buf != (char *)-1); /* Whether PROT_WRITE is readable is arch-dependent. So compare - * against read result. */ - res = read(rwfd, buf, SIZE); + * against write() result (to make the kernel read from buf). */ + res = write(rwfd, buf, SIZE); if (res < 0) res = -errno; - status |= attempt_rw(rwfd, buf, SIZE, 0, READ, res); - - status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, SIZE); + status |= attempt_rw(rwfd, buf, SIZE, 0, READ, SIZE); + status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, res); return status; } |