<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style='--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;'>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>
<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>
<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style='font-size: inherit; -webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";'>
<div class="content">
<p class="details" style="font-style: italic; color: #626168;">
<a href="https://gitlab.rtems.org/sebhub">Sebastian Huber</a> created a merge request: <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/725">!725</a>
</p>
<div class="branch">
Project:Branches: sebhub/rtems:rtems-6-fix-libio-iop-ref-count to rtems/rtos/rtems:6
</div>
<div class="author">
Author: Sebastian Huber
</div>
<div class="assignee">
Assignee: Sebastian Huber
</div>
<div class="reviewer">
Reviewer: Kinsey Moore
</div>
<div class="approvers">
</div>
<div class="md gl-mt-5" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word; margin-top: 1rem;">
<h2 dir="auto" style="margin-top: 0; margin-bottom: 10px;" align="initial">
<a href="#summary" aria-hidden="true" class="anchor" id="user-content-summary" style="margin-top: 0; margin-left: -20px; text-decoration: none; outline: none; position: absolute; width: 20px;"></a>Summary</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">libio: Fix reference counting of file descriptors</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Commit <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/commit/0cf6de01df734c11212e63134551ee344a10ecec" data-reference-type="commit" data-original="0cf6de01df734c11212e63134551ee344a10ecec" data-link="false" data-link-reference="false" data-commit="0cf6de01df734c11212e63134551ee344a10ecec" data-project="26" data-container="body" data-placement="top" title="cpukit/libio: Support close with IOP references held" class="gfm gfm-commit has-tooltip" style='font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; font-size: 95%; margin-top: 0;'>0cf6de01</a> introduced a couple of
issues:</p>
<ul dir="auto" style="text-align: initial; list-style-type: disc; margin: 0 0 1rem; padding: 0;">
<li style="margin-top: 0; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<p style="color: #3a383f; margin: 0 0 1rem;">ABI changes on a release branch</p>
</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<p style="color: #3a383f; margin: 0 0 1rem;">Redundant LIBIO_FLAGS_FREE flag: an iop is free if and only if it is
on the free list.</p>
</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<p style="color: #3a383f; margin: 0 0 1rem;">When the iop is freed, its reference count was set to zero. The iop
reference count must never be set to a specific value after
initialization at system start. The only valid operations are
increments and decrements.</p>
</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<p style="color: #3a383f; margin: 0 0 1rem;">In the iop free handling, there was a deadlock potential by obtaining
the libio lock while owning a file system lock.</p>
</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<p style="color: #3a383f; margin: 0 0 1rem;">The reference counting did not work at all under concurrent access.
This was indicated by the failing spintrcritical24 test program.</p>
</li>
</ul>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">To fix this, remove the LIBIO_FLAGS_FREE and change the flag values back
to the original values (restore ABI).</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Actions must be performed based on state changes (flags, reference
count) and not based on reading the current flags.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Remove dangerous functions rtems_libio_check_is_open(),
rtems_libio_iop_flags_bad_fd(), rtems_libio_iop_is_held(),
rtems_libio_iop_is_free(). The open property and references must be
determined by inspecting the flags returned by rtems_libio_iop_hold() or
similar.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">In order to support closing a file descriptor with active references
(LIBIO_FLAGS_CLOSE_BUSY), produce exactly one reference count while
opening a file through the new function rtems_libio_iop_open(). An
associated file node is freed when the reference count changes from one
to zero.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">This is an API change. Users of rtems_libio_allocate() must now call
rtems_libio_iop_open() to make the iop available for use.</p>
<p dir="auto" style="color: #3a383f; margin: 0;" align="initial">Update <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5201" data-reference-type="issue" data-original="#5201" data-link="false" data-link-reference="false" data-issue="28915" data-project="26" data-iid="5201" data-namespace-path="rtems/rtos/rtems" data-project-path="rtems/rtos/rtems" data-issue-type="issue" data-container="body" data-placement="top" title="Socket close fails with kqueue/kevent usage." class="gfm gfm-issue" style="margin-top: 0;">#5201 (closed)</a>.
Update <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5311" data-reference-type="issue" data-original="#5311" data-link="false" data-link-reference="false" data-issue="29167" data-project="26" data-iid="5311" data-namespace-path="rtems/rtos/rtems" data-project-path="rtems/rtos/rtems" data-issue-type="issue" data-container="body" data-placement="top" title="Backport Chris's libio fix to 6 branch" class="gfm gfm-issue">#5311</a>.</p>
</div>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #626168;">
—
<br>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/725">View it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.rtems.org">gitlab.rtems.org</a>. <a href="https://gitlab.rtems.org/-/sent_notifications/88b1a169c3e1c41842cfd4801476cad3/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.rtems.org/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.rtems.org/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<span style="color: transparent; font-size: 0; display: none; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0;">
Notification message regarding https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/725 at 1757919834
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Merge request","url":"https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/725"}}</script>
</p>
</div>
</body>
</html>