Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendfile syscall offset bug ??? #30741

Closed
malv-c opened this issue May 8, 2021 · 9 comments
Closed

sendfile syscall offset bug ??? #30741

malv-c opened this issue May 8, 2021 · 9 comments

Comments

@malv-c
Copy link

malv-c commented May 8, 2021

% uname -a
Linux x64-void 5.11.17_1 #1 SMP 1619738815 x86_64 GNU/Linux
sf4.txt
this is to test ;)

@ericonr
Copy link
Member

ericonr commented May 8, 2021

I'm not sure I understand. Does the 5.11.17 kernel have a bug?

@malv-c
Copy link
Author

malv-c commented May 8, 2021

i don't know that's why i ask...
with an easy test in asm ericonr

@Duncaen
Copy link
Member

Duncaen commented May 8, 2021

Its not an easy test, your test is broken for what its worth.

@ericonr
Copy link
Member

ericonr commented May 8, 2021

Is this not reproducible with C? What happens if you use sendfile as the function exposed by libc? Does it behave differently with different kernel versions?

@malv-c
Copy link
Author

malv-c commented May 9, 2021

sorry all you don't know asm
me too i restart it
but i know enough to understand that sendfile off_t refuse the integer lseek one accept
also the exit value and size_t work
sf.txt
commented source of working example for too busy people to change a value in code ;) Duncaen

% strace ./sf3-3 +255 =q sf3.s b*
execve("./sf3-3", ["./sf3-3", "+255", "=q", "sf3.s", "bb", "bh%", "bh0"], 0x7ffc6a137880 /* 42 vars /) = 0
open("q", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_NOATIME, 0777) = 3
open("sf3.s", O_RDONLY) = 4
sendfile(3, 4, NULL, 255) = 255
open("bb", O_RDONLY) = 5
sendfile(3, 5, NULL, 255) = 255
open("bh%", O_RDONLY) = 6
sendfile(3, 6, NULL, 255) = 255
open("bh0", O_RDONLY) = 11
sendfile(3, 11, NULL, 255) = 255
exit_group(0) = ?
+++ exited with 0 +++
/tmp
% strace ./sf3-3 ^255 =qf sf3.s b

execve("./sf3-3", ["./sf3-3", "^255", "=qf", "sf3.s", "bb", "bh%", "bh0"], 0x7ffde3499810 /* 42 vars */) = 0
open("qf", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_NOATIME, 0777) = 3
open("sf3.s", O_RDONLY) = 4
sendfile(3, 4, 0xff, 4611686018427387904) = -1 EFAULT (Bad address)
open("bb", O_RDONLY) = 5
sendfile(3, 5, 0xff, 4611686018427387904) = -1 EFAULT (Bad address)
open("bh%", O_RDONLY) = 6
sendfile(3, 6, 0xff, 4611686018427387904) = -1 EFAULT (Bad address)
open("bh0", O_RDONLY) = 11
sendfile(3, 11, 0xff, 4611686018427387904) = -1 EFAULT (Bad address)
exit_group(255) = ?
+++ exited with 255 +++

% strace ./sf3 +63 :q qq qqa qqs qqw
execve("./sf3", ["./sf3", "+63", ":q", "qq", "qqa", "qqs", "qqw"], 0x7ffeaec3d830 /* 42 vars /) = 0
open("q", O_RDONLY) = 3
open("qq", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_NOATIME, 0777) = 4
sendfile(4, 3, NULL, 63) = 63
open("qqa", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_NOATIME, 0777) = 5
lseek(3, 0, SEEK_SET) = 0
sendfile(5, 3, NULL, 63) = 63
open("qqs", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_NOATIME, 0777) = 6
lseek(3, 0, SEEK_SET) = 0
sendfile(6, 3, NULL, 63) = 63
open("qqw", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_NOATIME, 0777) = 11
lseek(3, 0, SEEK_SET) = 0
sendfile(11, 3, NULL, 63) = 63
exit_group(0) = ?
+++ exited with 0 +++
/tmp
% strace ./sf3 ^63 :q qq qqa qqs qqw
execve("./sf3", ["./sf3", "^63", ":q", "qq", "qqa", "qqs", "qqw"], 0x7ffcf6c22ce0 /
42 vars */) = 0
open("q", O_RDONLY) = 3
open("qq", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_NOATIME, 0777) = 4
sendfile(4, 3, 0x3f, 4611686018427387904) = -1 EFAULT (Bad address)
open("qqa", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_NOATIME, 0777) = 5
lseek(3, 63, SEEK_SET) = 63
sendfile(5, 3, 0x3f, 4611686018427387904) = -1 EFAULT (Bad address)
open("qqs", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_NOATIME, 0777) = 6
lseek(3, 63, SEEK_SET) = 63
sendfile(6, 3, 0x3f, 4611686018427387904) = -1 EFAULT (Bad address)
open("qqw", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_NOATIME, 0777) = 11
lseek(3, 63, SEEK_SET) = 63
sendfile(11, 3, 0x3f, 4611686018427387904) = -1 EFAULT (Bad address)
exit_group(63) = ?
+++ exited with 63 +++

% strace ./sf3 ^63 b*
execve("./sf3", ["./sf3", "^63", "bb", "bh%", "bh0"], 0x7ffff06f9d30 /* 42 vars /) = 0
open("bb", O_RDONLY) = 3
fcntl(1, F_SETFL, O_RDONLY) = 0
sendfile(1, 3, 0x3f, 4611686018427387904) = -1 EFAULT (Bad address)
open("bh%", O_RDONLY) = 4
sendfile(1, 4, 0x3f, 4611686018427387904) = -1 EFAULT (Bad address)
open("bh0", O_RDONLY) = 5
sendfile(1, 5, 0x3f, 4611686018427387904) = -1 EFAULT (Bad address)
exit_group(63) = ?
+++ exited with 63 +++
/tmp
% strace ./sf3 +63 b

execve("./sf3", ["./sf3", "+63", "bb", "bh%", "bh0"], 0x7fff8f955ab0 /* 42 vars */) = 0
open("bb", O_RDONLY) = 3
fcntl(1, F_SETFL, O_RDONLY) = 0
sendfile(1, 3, NULL, 63export HISTCONTROL=ignoredups:erasedups
shopt -s histreedit his) = 63
open("bh%", O_RDONLY) = 4
sendfile(1, 4, NULL, 63AE ri
M
man tr
ll /bin/tr
gcl https://github.com/coreutils/cor) = 63
open("bh0", O_RDONLY) = 5
sendfile(1, 5, NULL, 63./sbx -z
alsactl store
alsamixer
create_ap --help |more
ee /) = 63
exit_group(0) = ?
+++ exited with 0 +++

@malv-c
Copy link
Author

malv-c commented May 9, 2021

for small tasks the time c exec is loaded asm exec did the job ...
also to return to code in c may aska long time
and the c lib can put any values where it want
to know it you just have to verify the code
reverify it after compilation
with the hope nothing happen while installing
deal only with kernel problems is less painfull
anyway i can test anything you want ...

1 similar comment
@malv-c
Copy link
Author

malv-c commented May 9, 2021

for small tasks the time c exec is loaded asm exec did the job ...
also to return to code in c may aska long time
and the c lib can put any values where it want
to know it you just have to verify the code
reverify it after compilation
with the hope nothing happen while installing
deal only with kernel problems is less painfull
anyway i can test anything you want ...

@Duncaen
Copy link
Member

Duncaen commented May 9, 2021

This has nothing to do with void linux, you are using the syscall wrong. lseek takes off_t and sendfile takes a off_t pointer.

@Duncaen Duncaen closed this as completed May 9, 2021
@malv-c
Copy link
Author

malv-c commented May 9, 2021

sorry Duncaen
i didn't read the man correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants