[PATCH] Ensure that sendfile doesn't try to send beyond the end of the source file. Added some tests, and ensured that the same result is observed under both Linux and OSv.

2016-12-04 Thread Rick Payne
Fixes #815 Signed-off-by: Rick Payne --- fs/vfs/main.cc| 15 +++ tests/tst-sendfile.cc | 28 +++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/fs/vfs/main.cc b/fs/vfs/main.cc index 8fecc08..924bfad 100644 ---

Re: Problems in sendfile?

2016-12-04 Thread Nadav Har'El
On Sun, Dec 4, 2016 at 9:05 PM, Rick Payne wrote: > > What about something like the following. Not sure if you favour a > different approach rather than checking the extents in the sendfile code, > but this certainly gets me moving forward again. > Your patch looks good -

Re: Problems in sendfile?

2016-12-04 Thread Roman Shaposhnik
On Sun, Dec 4, 2016 at 12:34 AM, Avi Kivity wrote: > On 12/04/2016 04:00 AM, Roman Shaposhnik wrote: >> >> sendfile is a pretty Linux-centric API and I'm sure it isn't implemented >> by OSv. > > > OSv aims to be Linux compatible, and does implement sendfile() (though not >

Re: Problems in sendfile?

2016-12-04 Thread Rick Payne
What about something like the following. Not sure if you favour a different approach rather than checking the extents in the sendfile code, but this certainly gets me moving forward again. I can work on some tst-sendfile code too if you want - but don’t want to duplicate effort if you’re

[COMMIT osv master] pthread_mutex_trylock: Return EBUSY not -EBUSY

2016-12-04 Thread Commit Bot
From: Rick Payne Committer: Nadav Har'El Branch: master pthread_mutex_trylock: Return EBUSY not -EBUSY Signed-off-by: Rick Payne Message-Id: <1480693088-22453-1-git-send-email-ri...@rossfell.co.uk> --- diff --git

Re: Problems in sendfile?

2016-12-04 Thread Nadav Har'El
On Sun, Dec 4, 2016 at 11:00 AM, Nadav Har'El wrote: > > > I am guessing that the problem might be that the file is smaller than 1 > gigabyte, and the sendfile() is reading more than mmap() mapped and thus > getting a sigsegv. We need to see what Linux does in that case - does

Re: Problems in sendfile?

2016-12-04 Thread Avi Kivity
On 12/04/2016 04:00 AM, Roman Shaposhnik wrote: sendfile is a pretty Linux-centric API and I'm sure it isn't implemented by OSv. OSv aims to be Linux compatible, and does implement sendfile() (though not without problems, as we see). sendfile() originated in Solaris, IIRC, and variants