lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 30 Nov 2023 14:00:01 -0500
From:   Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To:     Tycho Andersen <tycho@...ho.pizza>,
        Florian Weimer <fweimer@...hat.com>
Cc:     Christian Brauner <brauner@...nel.org>,
        Oleg Nesterov <oleg@...hat.com>,
        "Eric W . Biederman" <ebiederm@...ssion.com>,
        linux-kernel@...r.kernel.org, linux-api@...r.kernel.org,
        Tycho Andersen <tandersen@...flix.com>
Subject: Re: [RFC 1/3] pidfd: allow pidfd_open() on non-thread-group leaders

On 2023-11-30 13:54, Tycho Andersen wrote:
> On Thu, Nov 30, 2023 at 07:37:02PM +0100, Florian Weimer wrote:
>> * Tycho Andersen:
>>
>>> From: Tycho Andersen <tandersen@...flix.com>
>>>
>>> We are using the pidfd family of syscalls with the seccomp userspace
>>> notifier. When some thread triggers a seccomp notification, we want to do
>>> some things to its context (munge fd tables via pidfd_getfd(), maybe write
>>> to its memory, etc.). However, threads created with ~CLONE_FILES or
>>> ~CLONE_VM mean that we can't use the pidfd family of syscalls for this
>>> purpose, since their fd table or mm are distinct from the thread group
>>> leader's. In this patch, we relax this restriction for pidfd_open().
>>
>> Does this mean that pidfd_getfd cannot currently be used to get
>> descriptors for a TID if that TID doesn't happen to share its descriptor
>> set with the thread group leader?
> 
> Correct, that's what I'm trying to solve.
> 
>> I'd like to offer a userspace API which allows safe stashing of
>> unreachable file descriptors on a service thread.
> 
> By "safe" here do you mean not accessible via pidfd_getfd()?

For the LTTng-UST use-case, we need to be able to create and
use a file descriptor from an agent thread injected within the target
process in a way that is safe against patterns where the application
blindly close all file descriptors (for-loop doing close(2),
closefrom(2) or closeall(2)).

The main issue here is that even though we could handle errors
(-1, errno=EBADF) in the sendmsg/recvmsg calls, re-use of a file
descriptor by the application can lead to data corruption, which
is certainly an unwanted consequence.

AFAIU glibc has similar requirements with respect to io_uring
file descriptors.

Thanks,

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ