Free NBD netlink sockets with nl_socket_free() #119

Merged
vitalif merged 1 commits from koolkhel/vitastor:nbd-netlink-sock-free into master 2026-11-17 10:21:46 +03:00
Contributor

Description

netlink_sock_free() released the socket from nl_socket_alloc() with a
plain free(), leaking its file descriptor and its callback set. With
LeakSanitizer, netlink-unmap then exits with a non-zero code.

Tested with an ASan build of uStor, whose nbd_proxy.cpp has the same function. Without the fix, netlink-unmap reported 224 bytes leaked in nl_cb_alloc() <- nl_socket_alloc() <- netlink_sock_alloc() <- netlink_disconnect() and exited non-zero. With it, there is no leak report and it exits 0.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description netlink_sock_free() released the socket from nl_socket_alloc() with a plain free(), leaking its file descriptor and its callback set. With LeakSanitizer, netlink-unmap then exits with a non-zero code. Tested with an ASan build of uStor, whose nbd_proxy.cpp has the same function. Without the fix, `netlink-unmap` reported 224 bytes leaked in nl_cb_alloc() <- nl_socket_alloc() <- netlink_sock_alloc() <- netlink_disconnect() and exited non-zero. With it, there is no leak report and it exits 0. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-16 22:03:09 +03:00
netlink_sock_free() released the socket from nl_socket_alloc() with a
plain free(), leaking its file descriptor and its callback set. With
LeakSanitizer, netlink-unmap then exits with a non-zero code.
vitalif merged commit 1ba35c3b5e into master 2026-11-17 10:21:46 +03:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#119
No description provided.