[Bug 282196] New: glibc is mangling the splice system call
https://bugzilla.novell.com/show_bug.cgi?id=282196 Summary: glibc is mangling the splice system call Product: openSUSE 10.2 Version: Final Platform: i386 OS/Version: Other Status: NEW Severity: Major Priority: P5 - None Component: Basesystem AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: axboe@kernel.dk QAContact: qa@suse.de On SUSE 10.2 and newer, test examples of splice do not work. Looking with strace, a: splice(3, 0, 1, 0x68b, 0); is turned into a splice(0x8048711, 0x3, 0, 0x1, 0, 0x68b); which obviously just fails. I'm attaching a test example. For testing, do: $ ./splice-in some_readable_file | cat and that should output the file on stdout. If splice is broken, it'll return nothing. undef USE_GLIBC_SPLICE to see it working, define it to see it break. Note that I have only observed this bug on i386, x86-64 seems to work. Since I don't have a x86-64 10.2 or newer available, I cannot test. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=282196 ------- Comment #1 from axboe@kernel.dk 2007-06-08 00:27 MST ------- Created an attachment (id=144931) --> (https://bugzilla.novell.com/attachment.cgi?id=144931&action=view) splice example test case -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=282196 ------- Comment #2 from axboe@kernel.dk 2007-06-08 01:38 MST ------- Created an attachment (id=144940) --> (https://bugzilla.novell.com/attachment.cgi?id=144940&action=view) splice header file -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=282196 matz@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |NEEDINFO Info Provider| |axboe@kernel.dk ------- Comment #3 from matz@novell.com 2007-06-08 06:03 MST ------- Can't reproduce with glibc-2.5-25 on a i586 10.2 system: After commenting out the "#define USE_GLIBC_SPLICE" from the source: % gcc splice-test.c % ./a.out splice-test.h | cat splice: Invalid argument % strace ./a.out splice-test.h 2>&1 | grep 313 SYS_313(0x3, 0, 0x1, 0, 0x99c) = -1 EINVAL (Invalid argument) % gcc -D USE_GLIBC_SPLICE splice-test.c % ./a.out splice-test.h | cat splice: Invalid argument strace ./a.out splice-test.h 2>&1 | grep 313 SYS_313(0x3, 0, 0x1, 0x99c) = -1 EINVAL (Invalid argument) I.e. exactly the same behaviour no matter if the syscall is called directly or over the glibc wrapper. I also see no mangling, the glibc wrapper expects 6 arguments (strace gives only 5 for unknown syscalls): in_fd, in_off, out_fd, out_off, len, flags which the program indeed passes in that order, with in_fd being 3 (the opened file), out_fd being 1 (stdout), both pointers to the filedescs being NULL (0 in strace output), and the len being the size of the file (0x99c which indeed is the filesize of my splice-test.h). So the call in the program and the syscall agree, and both give an EINVAL. Do you perhaps use a broken strace program which dumps the arguments incorrectly? (I note that yours seems to know the "splice" syscall, perhaps mine doesn't, so it's possible that the patch introducing that knowledge actually is broken?) -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=282196 ------- Comment #4 from axboe@kernel.dk 2007-06-08 06:10 MST ------- The test above was run on 10.3-alpha4, the strace there apparently knows about splice. Perhaps the compile flags has something to do with it as well, try: gcc -Wall -O2 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 and see if it still works. EINVAL is somewhat odd, is the kernel too old? You should not see an EINVAL, unless your filesystem doesn't support splice. Again, that might be due to an older kernel. ext2/ext3/reiser should be fine since the beginning irc. Also, if you can give it a go on a 10.3-alpha and verify with strace there as well, it would help. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=282196 axboe@kernel.dk changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |ASSIGNED Info Provider|axboe@kernel.dk | ------- Comment #5 from axboe@kernel.dk 2007-06-08 06:32 MST ------- I should mention that I have two external reports telling me about the same mangling, it's not just something that I see here. Hugh Dickins writes: "By the way, do you know anything about i386 splice being broken at the glibc end on openSUSE 10.2? When I built your splice testing tools on i386, I couldn't get more than a 0-length output file from splice-cp, and was beginning to believe splice just a con trick. But works right on x86_64 (64-bit kernel and 64-bit userspace, didn't try 32-bit splice-cp there) and powerpc (64-bit kernel and 32-bit userspace, didn't try other combinations), and works right on Fedora Core 6. Somehow 10.2's i386 glibc seems to be inserting an address at the beginning of the arg list, shifting all the others down. I've ended up modifying your splice.h to #define things over to using the inline syscalls instead. I didn't check whether the same happens with tee and vmsplice." and someone on Ubuntu 7.04 i686 writes reported the same the other day, symptoms are EXACTLY the same, arguments being mangled. He also reports that doing the syscall "manually" makes everything work fine. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=282196 ------- Comment #6 from axboe@kernel.dk 2007-06-08 06:36 MST ------- You need -D_GNU_SOURCE at least, otherwise you wont see the glibc defines for splice. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=282196 matz@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|bnc-team- |pbaudis@novell.com |screening@forge.provo.novell| |.com | Status|ASSIGNED |NEW ------- Comment #7 from matz@novell.com 2007-06-08 07:16 MST ------- Ah well, please tell that next time, I was testing in my homedir (NFS) ;) Now I don't get EINVALs. It instead now works just fine in both cases, with or without using the glibc wrapper. kernel is kernel-default-2.6.18.2-34. Using your compile flags indeed does break it though in the glibc-wrapper case indeed. It's the -D_GNU_SOURCE, which breaks it, because only then the glibc wrapper is used at all. Without it SPLICE_F_MOVE will not be defined and hence your own header will provide the splice() wrapper, which I missed before. Okay, glibc indeed has a bug here. The problem (I think) is in ./sysdeps/unix/sysv/linux/i386/sysdep.h, in the (extremely seldomly used) DOARGS_6 macro. It's used only from the syscall() function itself, and then for automatically generated wrapper for 6 argument syscalls (of which splice() is one). The problem here is these definitions: #define DOARGS_4 _DOARGS_4 (24) #define _PUSHARGS_4 pushl %esi; ... .. #define DOARGS_5 _DOARGS_5 (32) #define _PUSHARGS_5 pushl %edi; ... .. #define DOARGS_6 _DOARGS_6 (36) #define _PUSHARGS_6 pushl %ebp; ... Note how the important number (used as offset from %esp) has a gap of eight between the 4 and 5 argument case. This accounts for the step to the next argument (given on the stack by the caller of functions using these macros), plus the adjustment because we emit the "pushl %edi" before, which changes %esp by four more. This is also the gap between DOARGS_3 and DOARGS_4. The exact same pattern happens in DOARGS_6 (it pushes %ebp), but still the gap is only 4. This results in a shift of arguments by exactly four bytes, or one argument overall, which can be seen quite nicely in the strace: splice(0x8048711, 0x3, 0, 0x1, 0, 0x68b); the 0x8048711 actually is the return address. The fix should be easy: substitute the faulty line by: #define DOARGS_6 _DOARGS_6 (40) ... Ohh, I just see that this was fixed in upstream glibc on 2006-10-11 by: 2006-10-11 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/syscalls.list: Add epoll_pwait. * sysdeps/unix/sysv/linux/sys/epoll.h: Declare epoll_pwait. * sysdeps/unix/sysv/linux/Versions (libc): Add epoll_pwait for version GLIBC_2.6. * Versions.def: Add GLIBC_2.6 for libc. * sysdeps/unix/sysv/linux/i386/sysdep.h (DOARGS_6): Fix offset. Bah, that was about four days after we froze glibc for 10.2 :-( Assigning to Petr to make sure our upcoming glibc has the fix, and perhaps to roll an online update if deemed usefull. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=282196 ------- Comment #8 from axboe@kernel.dk 2007-06-08 07:28 MST ------- Sorry, I should have mentioned this fact, nfs wont have splice support until 2.6.23 I'm afraid. Thanks for the analysis! Note that 10.3-alpha4 is also broken, so that needs an update as well. As this problem would affect any (automatically generated, I guess from the syscalls.list file) 6-arg system calls, I'd say it's a bit more important than if it was just splice. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=282196 pbaudis@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |NEEDINFO Info Provider| |ast@novell.com ------- Comment #9 from pbaudis@novell.com 2007-06-08 07:58 MST ------- STABLE now has glibc-2.6 so this should be fixed in next 10.3 alphas. We don't usually do online updates for non-enterprise releases except for security bugs, needinfo on Anja to confirm. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=282196 aj@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aj@novell.com ------- Comment #10 from aj@novell.com 2007-06-08 09:06 MST ------- We do these updates for critical bugs as well. I would propose to do this update together with the next round of timezone updates. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=282196 Petr Baudis <pbaudis@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |325986 -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=282196 Bug 282196 depends on bug 325986, which changed state. Bug 325986 Summary: glibc updates queued for next 10.2 update https://bugzilla.novell.com/show_bug.cgi?id=325986 What |Old Value |New Value ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=282196#c12 Petr Baudis <pbaudis@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #12 from Petr Baudis <pbaudis@novell.com> 2007-11-20 20:39:55 MST --- This should've been released. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com