qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] qemu-sockets: fix unix socket path copy (again)


From: Michael Tokarev
Subject: Re: [PATCH] qemu-sockets: fix unix socket path copy (again)
Date: Wed, 1 Sep 2021 14:45:55 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

On 01.09.2021 12:52, Peter Maydell wrote:
On Wed, 1 Sept 2021 at 09:29, Michael Tokarev <mjt@tls.msk.ru> wrote:
...
We have sizeof(sockaddr_storage) space there. If the kernel returned
salen greather than that, this means we received only partial address
and can't rely on it. It is like snprintf() returning more bytes than
available in the buffer - it says how much bytes NEEDED.

I think that if we need to check that we should be checking that
at the point where we make the accept() or whatever other call
filled in the sockaddr. That is the point at which the code
either (a) knows that the buffer is guaranteed big enough and
can assert that if it likes or (b) may have some reasonable way
to deal with the failure, eg allocate a bigger buffer and retry,
and (c) it is also the point where the code knows how big the actual
buffer it passed to the kernel is and so can validly determine if
it was truncated.

I don't care where it is done, as long as what is done does not
break in real-life scenario.

Originally I asked another question: WHY we ask for the socket name
in the first place, why do we need it, where do we use it?

Maybe we should answer to this one first and maybe remove whole
thing completely instead of fixing something which isn't used?

We don't check that the address is not truncated in any of the
other sockaddr-type-to-SocketAddress conversion functions...

Because other addresses have fixed length. If anything there does
not fit or is not equal to the expected length, the hell will break
loose for every application out there, qemu will note be the first
to look for..

/mjt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]