<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/samples/pidfd, branch v5.5</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.5</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.5'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2019-06-24T13:55:50Z</updated>
<entry>
<title>samples: make pidfd-metadata fail gracefully on older kernels</title>
<updated>2019-06-24T13:55:50Z</updated>
<author>
<name>Dmitry V. Levin</name>
<email>ldv@altlinux.org</email>
</author>
<published>2019-06-23T11:28:00Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bee19cd8f241ab3cd1bf79e03884e5371f9ef514'/>
<id>urn:sha1:bee19cd8f241ab3cd1bf79e03884e5371f9ef514</id>
<content type='text'>
Initialize pidfd to an invalid descriptor, to fail gracefully on
those kernels that do not implement CLONE_PIDFD and leave pidfd
unchanged.

Signed-off-by: Dmitry V. Levin &lt;ldv@altlinux.org&gt;
Signed-off-by: Christian Brauner &lt;christian@brauner.io&gt;
</content>
</entry>
<entry>
<title>samples: fix pidfd-metadata compilation</title>
<updated>2019-06-05T13:06:07Z</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2019-05-30T11:40:47Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7c33277b9a9ada187f805b41ffbebe6c51622fb6'/>
<id>urn:sha1:7c33277b9a9ada187f805b41ffbebe6c51622fb6</id>
<content type='text'>
Define __NR_pidfd_send_signal if it isn't to prevent a compilation error.

To make pidfd-metadata compile on all arches, irrespective of whether
or not syscall numbers are assigned, define the syscall number to -1.
If it isn't defined this will cause the kernel to return -ENOSYS.

Fixes: 43c6afee48d4 ("samples: show race-free pidfd metadata access")
Reported-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Reported-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Cc: Christian Brauner &lt;christian@brauner.io&gt;
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
[christian@brauner.io: tweak commit message]
Signed-off-by: Christian Brauner &lt;christian@brauner.io&gt;
</content>
</entry>
<entry>
<title>samples: add .gitignore for pidfd-metadata</title>
<updated>2019-05-10T09:50:52Z</updated>
<author>
<name>Christian Brauner</name>
<email>christian@brauner.io</email>
</author>
<published>2019-05-08T11:02:30Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8b0e1fea3056a411300fb3a2d8f3ca9af54ace44'/>
<id>urn:sha1:8b0e1fea3056a411300fb3a2d8f3ca9af54ace44</id>
<content type='text'>
Ignore the pidfd-metadata binary so it doesn't show up in unwanted
scenarios.

Reported-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Christian Brauner &lt;christian@brauner.io&gt;
</content>
</entry>
<entry>
<title>samples: show race-free pidfd metadata access</title>
<updated>2019-05-07T12:31:04Z</updated>
<author>
<name>Christian Brauner</name>
<email>christian@brauner.io</email>
</author>
<published>2019-04-07T19:18:11Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=43c6afee48d4d866d5eb984d3a5dbbc7d9b4e7bf'/>
<id>urn:sha1:43c6afee48d4d866d5eb984d3a5dbbc7d9b4e7bf</id>
<content type='text'>
This is a sample program showing userspace how to get race-free access
to process metadata from a pidfd.  It is rather easy to do and userspace
can actually simply reuse code that currently parses a process's status
file in procfs.
The program can easily be extended into a generic helper suitable for
inclusion in a libc to make it even easier for userspace to gain metadata
access.

Since this came up in a discussion because this API is going to be used
in various service managers: A lot of programs will have a whitelist
seccomp filter that returns &lt;some-errno&gt; for all new syscalls.  This
means that programs might get confused if CLONE_PIDFD works but the
later pidfd_send_signal() syscall doesn't.  Hence, here's a ahead of
time check that pidfd_send_signal() is supported:

bool pidfd_send_signal_supported()
{
        int procfd = open("/proc/self", O_DIRECTORY | O_RDONLY | O_CLOEXEC);
        if (procfd &lt; 0)
                return false;

        /*
         * A process is always allowed to signal itself so
         * pidfd_send_signal() should never fail this test. If it does
         * it must mean it is not available, blocked by an LSM, seccomp,
         * or other.
         */
        return pidfd_send_signal(procfd, 0, NULL, 0) == 0;
}

Signed-off-by: Christian Brauner &lt;christian@brauner.io&gt;
Co-developed-by: Jann Horn &lt;jannh@google.com&gt;
Signed-off-by: Jann Horn &lt;jannh@google.com&gt;
Reviewed-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Cc: Arnd Bergmann &lt;arnd@arndb.de&gt;
Cc: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
Cc: Kees Cook &lt;keescook@chromium.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Cc: "Michael Kerrisk (man-pages)" &lt;mtk.manpages@gmail.com&gt;
Cc: Andy Lutomirsky &lt;luto@kernel.org&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Aleksa Sarai &lt;cyphar@cyphar.com&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
</feed>
