<feed xmlns='http://www.w3.org/2005/Atom'>
<title>passt/util.c, branch 2026_10_02.cba3570</title>
<subtitle>Plug A Simple Socket Transport</subtitle>
<link rel='alternate' type='text/html' href='https://passt.top/passt/'/>
<entry>
<title>util: Make setting uidmap and gidmap errors non-fatal</title>
<updated>2026-10-02T21:04:24+00:00</updated>
<author>
<name>Stefano Brivio</name>
<email>sbrivio@redhat.com</email>
</author>
<published>2026-10-02T06:55:54+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=a51d395de1daca9ddd3be4d5255e867cb4d470f9'/>
<id>a51d395de1daca9ddd3be4d5255e867cb4d470f9</id>
<content type='text'>
Starting from commit 7bf1595c9242 ("isolation: Don't create our userns
as nobody"), we unconditionally set uidmap and gidmap in the detached
user namespace.

If passt is started from a detached PID namespace, but /proc hasn't
been remounted to reflect this, we'll fail to write those entries.

That's actually fine as uidmap and gidmap are something that, strictly
speaking, we only need to write in pasta mode when a command is
detached (it's now done in all cases for simplicity).

Warn, because it's not the expected behaviour (/proc should probably
be remounted first), but don't fail on that.

Reported-by: Qiyu Yan &lt;yanqiyu@fedoraproject.org&gt;
Link: https://github.com/containers/crun/issues/2283
Suggested-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Starting from commit 7bf1595c9242 ("isolation: Don't create our userns
as nobody"), we unconditionally set uidmap and gidmap in the detached
user namespace.

If passt is started from a detached PID namespace, but /proc hasn't
been remounted to reflect this, we'll fail to write those entries.

That's actually fine as uidmap and gidmap are something that, strictly
speaking, we only need to write in pasta mode when a command is
detached (it's now done in all cases for simplicity).

Warn, because it's not the expected behaviour (/proc should probably
be remounted first), but don't fail on that.

Reported-by: Qiyu Yan &lt;yanqiyu@fedoraproject.org&gt;
Link: https://github.com/containers/crun/issues/2283
Suggested-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>util, pasta: Remove some unneeded #includes</title>
<updated>2026-09-08T14:11:28+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-08-21T05:04:02+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=cef6bce489ed9677fed7dcba602e77c726d3fd1a'/>
<id>cef6bce489ed9677fed7dcba602e77c726d3fd1a</id>
<content type='text'>
Presumably these mattered at some point in the past, but no longer.  Found
by clangd as invoked by Zed editor.  Not sure why direct clang-tidy runs
didn't spot these.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Presumably these mattered at some point in the past, but no longer.  Found
by clangd as invoked by Zed editor.  Not sure why direct clang-tidy runs
didn't spot these.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>util: Add missing O_CLOEXEC for !HAS_GETRANDOM path</title>
<updated>2026-09-08T14:11:26+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-08-21T05:04:01+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=cf3a11f40210248d80194be2d5404ababeaeb17f'/>
<id>cf3a11f40210248d80194be2d5404ababeaeb17f</id>
<content type='text'>
It rarely matters, since we usually have getrandom(), but in case we don't
our open() of /dev/random was missing O_CLOEXEC, which can cause clang
warnings.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It rarely matters, since we usually have getrandom(), but in case we don't
our open() of /dev/random was missing O_CLOEXEC, which can cause clang
warnings.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>util: Eliminate a stray trailing whitespace</title>
<updated>2026-09-08T14:11:24+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-08-21T05:04:00+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=abdc94a25679259ee88418a48145a264b37f7794'/>
<id>abdc94a25679259ee88418a48145a264b37f7794</id>
<content type='text'>
We generally avoid trailing whitespace, but one slipped in.  Fix it.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We generally avoid trailing whitespace, but one slipped in.  Fix it.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>util, pasta: Generalise [ug]id_map creation</title>
<updated>2026-09-08T14:00:19+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-08-20T05:30:31+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=9587a355ff6ed05a92ba226cc2a37e113c1d106c'/>
<id>9587a355ff6ed05a92ba226cc2a37e113c1d106c</id>
<content type='text'>
pasta_start_ns() creates UID and GID mappings for the user namespace in
which the child process runs.  We're going to want some more flexible
variants of this, so move it into a more general helper function
make_ugid_map() which will make a single user UID/GID mapping for the
userns owned by a given PID.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
pasta_start_ns() creates UID and GID mappings for the user namespace in
which the child process runs.  We're going to want some more flexible
variants of this, so move it into a more general helper function
make_ugid_map() which will make a single user UID/GID mapping for the
userns owned by a given PID.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>isolation: Include linux_dep.h for close_range()</title>
<updated>2026-08-10T16:25:34+00:00</updated>
<author>
<name>Huang Jing</name>
<email>rne.kou@icloud.com</email>
</author>
<published>2026-08-07T16:10:32+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=defc25b9444c508d21badb6bc9a0b835ddd01126'/>
<id>defc25b9444c508d21badb6bc9a0b835ddd01126</id>
<content type='text'>
Include linux_dep.h for close_range() usage in isolation.c. And now
that the close_open_files() function which makes use of linux_dep.h
has been moved from util.c to isolation.c, we can safely remove the
header inclusion from util.c.

Link: https://github.com/gentoo/gentoo/pull/46644
Fixes: 0a510066e916 ("isolation: Move close_open_files() to isolate_fds()")
Signed-off-by: Jing Huang &lt;rne.kou@icloud.com&gt;
Reviewed-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Include linux_dep.h for close_range() usage in isolation.c. And now
that the close_open_files() function which makes use of linux_dep.h
has been moved from util.c to isolation.c, we can safely remove the
header inclusion from util.c.

Link: https://github.com/gentoo/gentoo/pull/46644
Fixes: 0a510066e916 ("isolation: Move close_open_files() to isolate_fds()")
Signed-off-by: Jing Huang &lt;rne.kou@icloud.com&gt;
Reviewed-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>main: Ensure fds 0-2 are populated</title>
<updated>2026-07-18T07:54:37+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-07-17T05:46:34+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=c80d9db312dfa98909bf3b3a5b2655785cdb3b07'/>
<id>c80d9db312dfa98909bf3b3a5b2655785cdb3b07</id>
<content type='text'>
Usually fds 0-2 are stdin, stdout and stderr.  However, there are certain
use cases where passt can be invoked with one or more of those standard fds
closed.  In those cases, anything we open might be placed in one of the
standard slots.  For the handful of things we open early enough, this can
be a problem because we close fds 0-2 in __daemon(), replacing them with
dupes of /dev/null.

We could avoid closing those fds in __daemon() if they're not standard
streams.  However, leaving things other than the standard streams in fds
0-2 is a footgun: a stray printf() that occurs in a circumstance it
shouldn't could send harmful garbage to a device or socket.  It's also
likely to be confusing if debugging with strace or similar.

To avoid this, fill any missing standard streams with a dupe of /dev/null,
right after isolate_fds().  Since open()ing /dev/null itself could land in
one of those fd 0-2 slots, we need to be careful when we close it not to
leave a new gap.

Link: https://bugs.passt.top/show_bug.cgi?id=215
Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Usually fds 0-2 are stdin, stdout and stderr.  However, there are certain
use cases where passt can be invoked with one or more of those standard fds
closed.  In those cases, anything we open might be placed in one of the
standard slots.  For the handful of things we open early enough, this can
be a problem because we close fds 0-2 in __daemon(), replacing them with
dupes of /dev/null.

We could avoid closing those fds in __daemon() if they're not standard
streams.  However, leaving things other than the standard streams in fds
0-2 is a footgun: a stray printf() that occurs in a circumstance it
shouldn't could send harmful garbage to a device or socket.  It's also
likely to be confusing if debugging with strace or similar.

To avoid this, fill any missing standard streams with a dupe of /dev/null,
right after isolate_fds().  Since open()ing /dev/null itself could land in
one of those fd 0-2 slots, we need to be careful when we close it not to
leave a new gap.

Link: https://bugs.passt.top/show_bug.cgi?id=215
Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>isolation: Move close_open_files() to isolate_fds()</title>
<updated>2026-07-18T07:54:24+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-07-17T05:46:30+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=0a510066e9169409e9021798224bea5297c1e529'/>
<id>0a510066e9169409e9021798224bea5297c1e529</id>
<content type='text'>
Most functions in util.c are, well, utilities, that are useful in a bunch
of places.  close_open_files(), however, is very specific, it's only called
from isolate_initial(), and performs a very specific step of our self
isolation.  So, it makes more sense as a function in isolate.c - move it
there and rename it to isolate_fds().

In addition, call it directly from main() rather than from
isolate_initial().  That's pretty arbitrary now, but will make some
subsequent changes easier.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Most functions in util.c are, well, utilities, that are useful in a bunch
of places.  close_open_files(), however, is very specific, it's only called
from isolate_initial(), and performs a very specific step of our self
isolation.  So, it makes more sense as a function in isolate.c - move it
there and rename it to isolate_fds().

In addition, call it directly from main() rather than from
isolate_initial().  That's pretty arbitrary now, but will make some
subsequent changes easier.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>conf: Remove duplicate parsing of -F option</title>
<updated>2026-07-04T11:13:59+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-07-03T03:54:36+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=2cdb27a32f3d494109d7eb3737fb7362340515c1'/>
<id>2cdb27a32f3d494109d7eb3737fb7362340515c1</id>
<content type='text'>
The -F option is parsed in conf() along with everything else.  However,
because it informs what fds we can close at startup, we also have a special
case parse of it in close_open_files().

At present we duplicate the parsing and validation code, which is a bit
risky.  Avoid that with a conf_tap_fd() helper.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The -F option is parsed in conf() along with everything else.  However,
because it informs what fds we can close at startup, we also have a special
case parse of it in close_open_files().

At present we duplicate the parsing and validation code, which is a bit
risky.  Avoid that with a conf_tap_fd() helper.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>pif, util: Move listen(2) call from sock_l4_() to pif_listen()</title>
<updated>2026-06-16T21:50:00+00:00</updated>
<author>
<name>David Gibson</name>
<email>david@gibson.dropbear.id.au</email>
</author>
<published>2026-06-16T01:09:36+00:00</published>
<link rel='alternate' type='text/html' href='https://passt.top/passt/commit/?id=ab2260a0c73623f51e95f922002393170d0abe1f'/>
<id>ab2260a0c73623f51e95f922002393170d0abe1f</id>
<content type='text'>
It's a bit odd to have the listen(2) call for TCP listening sockets, down
deep in sock_l4_() conditional upon the epoll type passed in.  Move it to
pif_listen(), which is at least about listening, although it does still
need to be conditional on TCP.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It's a bit odd to have the listen(2) call for TCP listening sockets, down
deep in sock_l4_() conditional upon the epoll type passed in.  Move it to
pif_listen(), which is at least about listening, although it does still
need to be conditional on TCP.

Signed-off-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
