Bug 21738 - misc/tst-preadvwritev2 and misc/tst-preadvwritev64v2 fail
Summary: misc/tst-preadvwritev2 and misc/tst-preadvwritev64v2 fail
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.26
Assignee: Adhemerval Zanella
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-08 10:09 UTC by Markus Trippelsdorf
Modified: 2017-07-12 08:23 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2017-07-08 10:09:24 UTC
On X86_64 with glibc trunk:

FAIL: misc/tst-preadvwritev2                
FAIL: misc/tst-preadvwritev64v2 

both fail with:
error: tst-preadvwritev2-common.c:38: preadv2 did not fail with an invalid flag
Comment 1 Adhemerval Zanella 2017-07-10 12:08:47 UTC
Are you testing a 32 bit binary on a 64 bit kernel? This is a known kernel issue [1], otherwise it is new issue.

[1] https://sourceware.org/ml/libc-alpha/2017-06/msg00726.html
Comment 2 Markus Trippelsdorf 2017-07-10 12:50:51 UTC
(In reply to Adhemerval Zanella from comment #1)
> Are you testing a 32 bit binary on a 64 bit kernel? This is a known kernel
> issue [1], otherwise it is new issue.
> 
> [1] https://sourceware.org/ml/libc-alpha/2017-06/msg00726.html

No, this is on X86_64 (64 bit binaries only) running Linux latest git.
Comment 3 Adhemerval Zanella 2017-07-10 13:04:06 UTC
In this case could you provide the result of a strace to check for kernel arguments?
Comment 4 Markus Trippelsdorf 2017-07-10 13:23:40 UTC
markus@x4 misc % strace ./tst-preadvwritev64v2
execve("./tst-preadvwritev64v2", ["./tst-preadvwritev64v2"], 0x7ffceb4c3710 /* 54 vars */) = 0                                                                                     
brk(NULL)                               = 0x75f000                                       
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4f5b0a8000
access("/etc/ld.so.preload", R_OK)      = 0 
openat(AT_FDCWD, "/etc/ld.so.preload", O_RDONLY|O_CLOEXEC) = 3                           
fstat(3, {st_mode=S_IFREG|0644, st_size=1, ...}) = 0                                     
mmap(NULL, 1, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0x7f4f5b0a7000                  
close(3)                                = 0 
munmap(0x7f4f5b0a7000, 1)               = 0 
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3                             
fstat(3, {st_mode=S_IFREG|0644, st_size=168310, ...}) = 0                                
mmap(NULL, 168310, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4f5b07e000                        
close(3)                                = 0 
openat(AT_FDCWD, "/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3                               
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\r\2\0\0\0\0\0"..., 832) = 832  
fstat(3, {st_mode=S_IFREG|0755, st_size=16590728, ...}) = 0                              
mmap(NULL, 3873088, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4f5aad0000                                                                                         
mprotect(0x7f4f5ac78000, 2097152, PROT_NONE) = 0                                         
mmap(0x7f4f5ae78000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a8000) = 0x7f4f5ae78000                                                               
mmap(0x7f4f5ae7e000, 14656, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f4f5ae7e000                                                                     
close(3)                                = 0 
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4f5b07b000                                                                                         
arch_prctl(ARCH_SET_FS, 0x7f4f5b07b740) = 0 
mprotect(0x7f4f5ae78000, 16384, PROT_READ) = 0                                           
mprotect(0x603000, 4096, PROT_READ)     = 0 
mprotect(0x7f4f5b0aa000, 4096, PROT_READ) = 0                                            
munmap(0x7f4f5b07e000, 168310)          = 0 
mmap(NULL, 8, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0) = 0x7f4f5b0a7000    
brk(NULL)                               = 0x75f000                                       
brk(0x780000)                           = 0x780000                                       
getpid()                                = 14335                                          
openat(AT_FDCWD, "/tmp/tst-preadvwritev.WTFpsh", O_RDWR|O_CREAT|O_EXCL, 0600) = 3        
getpid()                                = 14335                                          
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f4f5b07ba10) = 14336                                                                
rt_sigaction(SIGALRM, {sa_handler=0x401c80, sa_mask=[ALRM], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f4f5ab06eb0}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0     
alarm(20)                               = 0 
error: tst-preadvwritev2-common.c:38: preadv2 did not fail with an invalid flag          
rt_sigaction(SIGINT, {sa_handler=0x401c80, sa_mask=[INT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f4f5ab06eb0}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0       
wait4(14336, [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 14336                   
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=14336, si_uid=1000, si_status=1, si_utime=0, si_stime=0} ---                                                             
write(1, "error: 1 test failures\n", 23error: 1 test failures                            
) = 23                                      
getpid()                                = 14335                                          
unlink("/tmp/tst-preadvwritev.WTFpsh")  = 0 
exit_group(1)                           = ? 
+++ exited with 1 +++
Comment 5 Markus Trippelsdorf 2017-07-10 13:27:16 UTC
Sorry. Here is the correct one with -f:

markus@x4 misc % strace -f  ./tst-preadvwritev64v2
execve("./tst-preadvwritev64v2", ["./tst-preadvwritev64v2"], 0x7ffda01d8588 /* 54 vars */) = 0
brk(NULL)                               = 0xe13000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7febcf76b000
access("/etc/ld.so.preload", R_OK)      = 0
openat(AT_FDCWD, "/etc/ld.so.preload", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1, ...}) = 0
mmap(NULL, 1, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0x7febcf76a000
close(3)                                = 0
munmap(0x7febcf76a000, 1)               = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=168310, ...}) = 0
mmap(NULL, 168310, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7febcf741000
close(3)                                = 0
openat(AT_FDCWD, "/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\r\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=16590728, ...}) = 0
mmap(NULL, 3873088, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7febcf193000
mprotect(0x7febcf33b000, 2097152, PROT_NONE) = 0
mmap(0x7febcf53b000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a8000) = 0x7febcf53b000
mmap(0x7febcf541000, 14656, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7febcf541000
close(3)                                = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7febcf73e000
arch_prctl(ARCH_SET_FS, 0x7febcf73e740) = 0
mprotect(0x7febcf53b000, 16384, PROT_READ) = 0
mprotect(0x603000, 4096, PROT_READ)     = 0
mprotect(0x7febcf76d000, 4096, PROT_READ) = 0
munmap(0x7febcf741000, 168310)          = 0
mmap(NULL, 8, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0) = 0x7febcf76a000
brk(NULL)                               = 0xe13000
brk(0xe34000)                           = 0xe34000
getpid()                                = 2396
openat(AT_FDCWD, "/tmp/tst-preadvwritev.fjOakq", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
getpid()                                = 2396
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7febcf73ea10) = 2398
rt_sigaction(SIGALRM, {sa_handler=0x401c80, sa_mask=[ALRM], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7febcf1c9eb0}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
alarm(20)                               = 0
rt_sigaction(SIGINT, {sa_handler=0x401c80, sa_mask=[INT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7febcf1c9eb0}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
wait4(2398, strace: Process 2398 attached
 <unfinished ...>
[pid  2398] prlimit64(0, RLIMIT_CORE, {rlim_cur=0, rlim_max=0}, NULL) = 0
[pid  2398] setpgid(0, 0)               = 0
[pid  2398] preadv2(3, [{iov_base="", iov_len=32}], 1, 0, 0x8 /* RWF_??? */) = 0
[pid  2398] write(1, "error: tst-preadvwritev2-common."..., 38error: tst-preadvwritev2-common.c:38: ) = 38
[pid  2398] write(1, "preadv2 did not fail with an inv"..., 41preadv2 did not fail with an invalid flag) = 41
[pid  2398] write(1, "\n", 1
)           = 1
[pid  2398] getpid()                    = 2398
[pid  2398] exit_group(1)               = ?
[pid  2398] +++ exited with 1 +++
<... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 2398
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2398, si_uid=1000, si_status=1, si_utime=0, si_stime=0} ---
write(1, "error: 1 test failures\n", 23error: 1 test failures
) = 23
getpid()                                = 2396
unlink("/tmp/tst-preadvwritev.fjOakq")  = 0
exit_group(1)                           = ?
+++ exited with 1 +++
Comment 6 Markus Trippelsdorf 2017-07-10 13:36:04 UTC
See the following:

commit b745fafaf70c0a98a2e1e7ac8cb14542889ceb0e
Author: Goldwyn Rodrigues <rgoldwyn@suse.com>
Date:   Tue Jun 20 07:05:43 2017 -0500

    fs: Introduce RWF_NOWAIT and FMODE_AIO_NOWAIT
Comment 7 Adhemerval Zanella 2017-07-10 15:31:44 UTC
(In reply to Markus Trippelsdorf from comment #6)
> See the following:
> 
> commit b745fafaf70c0a98a2e1e7ac8cb14542889ceb0e
> Author: Goldwyn Rodrigues <rgoldwyn@suse.com>
> Date:   Tue Jun 20 07:05:43 2017 -0500
> 
>     fs: Introduce RWF_NOWAIT and FMODE_AIO_NOWAIT

That's explain the failure, I will create a patch.
Comment 8 Sourceware Commits 2017-07-11 14:09:15 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  94070f86c0c849c71ed2e7e2189bb4d1f7411a17 (commit)
      from  2a91300176a5991d9825eba085e502196a3f47cd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=94070f86c0c849c71ed2e7e2189bb4d1f7411a17

commit 94070f86c0c849c71ed2e7e2189bb4d1f7411a17
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Jul 10 15:53:32 2017 -0300

    posix: Add p{read,write}v2 RWF_NOWAIT flag (BZ#21738)
    
    Linux 4.12 (b745fafaf70c0a98a2e1e7ac8cb14542889ceb0e) adds a new
    p{read,write}v2 flag RWF_NOWAIT.  This patch adds it for linux
    uio-ext.h header.
    
    Checked on x86_64-linux-gnu (on a 4.10 kernel).
    
    	[BZ #21738]
    	* manual/llio.texi (RWF_NOWAIT): New item.
    	* misc/tst-preadvwritev2-common.c (do_test_with_invalid_flags):
    	Add RWF_NOWAIT check.
    	* sysdeps/unix/sysv/linux/bits/uio-ext.h (RWF_NOWAIT): New flag.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                              |    8 ++++++++
 manual/llio.texi                       |    4 ++++
 misc/tst-preadvwritev2-common.c        |   15 +++++----------
 sysdeps/unix/sysv/linux/bits/uio-ext.h |    1 +
 4 files changed, 18 insertions(+), 10 deletions(-)
Comment 9 Adhemerval Zanella 2017-07-11 14:12:20 UTC
Fixed by 94070f86c0c849c71ed2e7e2189bb4d1f7411a17.