Subject: Re: [boost] [AFIO] Formal review
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2015-09-01 19:28:21
On 31 Aug 2015 at 20:31, Giovanni Piero Deretta wrote:
> what happens if another process truncates the file while I'm writing
> to it?
Right now, a denial of service attack. I'm aware of it (see other
thread), but I need to replace the ASIO reactor to fix it.
> Also is the 'max size' cached? What happens if another process
> extends the file size, notifies me out of band of the new size and I
> write beyond the original limit?
AFIO doesn't second guess the kernel, and doesn't cache anything
anywhere at all in data structures it manages.
There is no out of bounds checking in the scatter gather read/write
implementation - all that AFIO knows is a read or write comes back
partial because that is all ASIO tells us. As you are guaranteed by
the OS that filesystem i/o is NEVER partial, something is seriously
wrong, so we fatal exit. Hence the message "buffers not filled".
> I would certainly hope that the application won't crash in neither
> scenario. It must never be possible for a process to cause another
> process in another address space to crash (discounting super user
> privileges or ptrace of course).
It better for controlled fatal exit than a security breach.
But yes, I agree. This denial of service attack is a problem, and I
hope to fix it in the engine refactor once ASIO isn't in the way.
-- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk