Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V2] Fix double close on ubivol descriptor #1421

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tvdstaaij
Copy link

The g_output_stream_close call was introduced at some point after the casync functionality for UBI was introduced (#501). This close call is fine for the copy_raw_image branch, but for the casync branch it causes the update to fail:

rauc[250]: Installation error: Failed updating slot rootfs.1: Error closing file descriptor: Bad file descriptor

This was also mentioned in #1200. However it was not investigated there but instead sidestepped by using a different update approach.

Investigation with strace shows that the descriptor is closed twice:

290   openat(AT_FDCWD, "/dev/ubi0_1", O_WRONLY|O_EXCL|O_LARGEFILE <unfinished ...>
290   <... openat resumed>)             = 8
[snip]
290   close(8 <unfinished ...>
290   <... close resumed>)              = 0
290   close(8 <unfinished ...>
290   <... close resumed>)              = -1 EBADF (Bad file descriptor)

This can be explained by the documentation of
g_subprocess_launcher_close():

Closes all the file descriptors previously passed to the object with
g_subprocess_launcher_take_fd(), g_subprocess_launcher_take_stderr_fd(), etc.
(...)
This function is called automatically when the #GSubprocessLauncher is disposed


Additional information

Rework of #1419

Copy link
Member

@jluebbe jluebbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just make a force-push with an updated commit to change this PR.

src/update_handler.c Outdated Show resolved Hide resolved
@jluebbe jluebbe added the fixed label May 15, 2024
@jluebbe jluebbe added this to the Release v1.12 milestone May 15, 2024
The g_output_stream_close call was introduced at some point after the
casync functionality for UBI was introduced (rauc#501). This close call is
fine for the copy_raw_image branch, but for the casync branch it causes
the update to fail:

rauc[250]: Installation error: Failed updating slot rootfs.1: \
    Error closing file descriptor: Bad file descriptor

This was also mentioned in rauc#1200. However it was not investigated there
but instead sidestepped by using a different update approach.

Investigation with strace shows that the descriptor is closed twice:

290   openat(AT_FDCWD, "/dev/ubi0_1", O_WRONLY|O_EXCL|O_LARGEFILE <unfinished ...>
290   <... openat resumed>)             = 8
[snip]
290   close(8 <unfinished ...>
290   <... close resumed>)              = 0
290   close(8 <unfinished ...>
290   <... close resumed>)              = -1 EBADF (Bad file descriptor)

This can be explained by the documentation of
g_subprocess_launcher_close():

> Closes all the file descriptors previously passed to the object with
> g_subprocess_launcher_take_fd(), g_subprocess_launcher_take_stderr_fd(), etc.
> (...)
> This function is called automatically when the #GSubprocessLauncher is disposed

Signed-off-by: Tim van der Staaij <[email protected]>
@tvdstaaij tvdstaaij force-pushed the fix_double_close_on_ubivol_v2 branch from 7b93851 to be6c0fb Compare May 15, 2024 11:54
@tvdstaaij tvdstaaij requested a review from jluebbe May 15, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants