[PATCH] libnl: report an error if unexpected control data was received

Andrey Vagin avagin at openvz.org
Mon Sep 21 04:59:50 PDT 2015


2015-09-21 13:00 GMT+03:00 Thomas Haller <thaller at redhat.com>:
> On Mon, 2015-09-14 at 18:59 +0300, Andrey Vagin wrote:
>> Currently, we try to handle MSG_CTRUNC, but if msg_controllen is
>> zero, we make
>> double free for the same address.
>>
>> realloc(0, 0) returns non-zero address
>> realloc(addr, 0) returns zero and free(addr) has already been called
>>
>> Then we call free(addr) again and get an error like this:
>
> Hi Andrey,
>
>
> could you elaborate a bit on the circumstances when you hit this error?

It was my fault. I used setsockopts to set SO_PASSCREDS instead of
nl_socket_set_passcred, so NL_SOCK_PASSCRED was not set for the
nl_sock object and libnl didn't expect to get control data.

Thanks,
Andrew.

> Did the kernel set msg_controllen to zero? Do you know why?
>
>
> Anyway, thanks for the patch!!
> Applied as https://github.com/thom311/libnl/commit/fd9d1da28c9d989f88b6c5edaa352c01976f82ac
>
>
>
> Thomas



More information about the libnl mailing list