Skip to content

ubus fixes#372

Open
nbd168 wants to merge 2 commits intojow-:masterfrom
nbd168:ubus-fix
Open

ubus fixes#372
nbd168 wants to merge 2 commits intojow-:masterfrom
nbd168:ubus-fix

Conversation

@nbd168
Copy link
Copy Markdown
Contributor

@nbd168 nbd168 commented Feb 7, 2026

  • avoid double close of externally owned channel fds
  • fix refcounting bug

In uc_ubus_channel_req_cb an extra ref is taken for args and method,
which are not used elsewhere.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
When a channel is opened via an fd obtained through fileno(), the fd is
owned by an external resource. Track this in fd_handle and detach from
uloop without closing the fd on disconnect/shutdown.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
@jow-
Copy link
Copy Markdown
Owner

jow- commented Mar 15, 2026

The args/type refcount fix is straightforward and clear, but I do not understand the purpose of the external fd fix.

Why should we treat fd numbers obtained from someobj.fileno() different than straight integers? Either could be external and within the ubus module we do not create own or reuse external descriptors conditionally either.

Can you elaborate some more on the kind of issue you try to address with this fix? Should we rather never close fds at all in the channel case and leave it to the caller to clean them up?

@nbd168
Copy link
Copy Markdown
Contributor Author

nbd168 commented Mar 16, 2026

The args/type refcount fix is straightforward and clear, but I do not understand the purpose of the external fd fix.

Why should we treat fd numbers obtained from someobj.fileno() different than straight integers? Either could be external and within the ubus module we do not create own or reuse external descriptors conditionally either.

Can you elaborate some more on the kind of issue you try to address with this fix? Should we rather never close fds at all in the channel case and leave it to the caller to clean them up?

The change that I made addresses a nasty corner case in unetmsg, where the channel disconnect was closing the fd, and before the handle was freed (which would close the fd again), the fd number was already reused. This was causing the handle free to close an unrelated different open fd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants