pppd: Fix potential buffer overflow in lcp_rtt_update_buffer()#554
pppd: Fix potential buffer overflow in lcp_rtt_update_buffer()#554paulusmack merged 1 commit intoppp-project:masterfrom
Conversation
It's possible for ring_header[2] to be modified by another process when reading it twice through a volatile pointer, causing it to change from a small value (which doesn't need to wrap around) to a large value which would exceed the size of the buffer. Signed-off-by: Simon Arlott <git@sa.me.uk>
|
There are other things I don't like about this file format:
These can't be fixed without changing the file format making it incompatible with any existing user I have my own implementation that uses a socket instead of a file, I just need to rewrite it to be more generic |
|
I don't like this mechanism at all. I do approve of the change though. Other comments about this below. I'd personally use a struct to overlay onto the mmap()'ed memory, eg, something like: If two formats is made, then the ring array at the end should be a union of two structs, eg, ring_0 (old format) and ring_1 (new format). Naming it _0 and _1 assumes that we will possibly update it again later to _2. This does complicate the ftruncate option in file open. If you reed the comments about msync() just below the code you changed, it looks more like you need an msync() after each write to the memory region, including the ring header initilization code. Specifically: Thus the issue you're describing is known. I recommend you rather add an msync() between ring_bugger[next_entry + 1] = ... and ring_header[2] = ... as well. This will at least fix the synchronization problem you mentioned, not sure MS_ASYNC is good enough for that, probably either MS_SYNC and/or MS_INVALIDATE. |
|
I will not be attempting to fix the file format or the synchronisation. The underlying problem is that all writes to the file will be visible immediately to other processes in the shared memory used for the filesystem cache. The I don't want to add locking because that introduces a risk of blocking pppd indefinitely. |
|
I do agree with the change. Not that any other processes SHOULD be writing to the file. But if you have the same file for multiple pppd processes, then at least this will stop the buffer overflow. |
It's possible for
ring_header[2]to be modified by another process when reading it twice through a volatile pointer, causing it to change from a small value (which doesn't need to wrap around) to a large value which would exceed the size of the buffer.