From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 339D73858D28 for ; Mon, 24 Apr 2023 21:02:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 339D73858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pr3Jy-00006c-F9; Mon, 24 Apr 2023 17:02:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=GftHtwW4E2oUmvxhRD7pGhCAMJyvtJfj1Lz6aCxzTa0=; b=XpiAz4j9j3fnPNHgt7PD Vm/wCuEoKRQtHYEZY+PPwRHzyAZoODptXe5Q2/3V4ke+EEk8C4yuJms7mDi/OSSUfZu4r8D/Kk+WB eJNScjz1Lcj9Gp3482LZP5U4Oj4T4HX9wLnLBm7jhR4GHreCIlfSBPhfKU5LKiTcnihCL+PH8RPJc kDVS/3Jpk0SYgjAQqebmWYgwexagn/X+sszWRvrfjWAVBH24YeHOxHk073BOcIjpmU7vi4xlqasTl mGX+x3mcEE+F8ZKIJu4bxbSsB9Ag2kGb3arrURPBjGHJkygXn12geK06N5v7wC7fYJE83v5k3B0TJ Pdd2OYCaXfFkZA==; Received: from [2a01:cb19:4a:a400:de41:a9ff:fe47:ec49] (helo=begin.home) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pr3Jx-0004MM-TT; Mon, 24 Apr 2023 17:02:01 -0400 Received: from samy by begin.home with local (Exim 4.96) (envelope-from ) id 1pr3Jv-003uEI-2I; Mon, 24 Apr 2023 23:01:59 +0200 Date: Mon, 24 Apr 2023 23:01:59 +0200 From: Samuel Thibault To: Sergey Bugaev Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: Re: [PATCH v2 1/4] hurd: Don't pass FD_CLOEXEC in CMSG_DATA Message-ID: <20230424210159.xdmwk5oqfflwph2k@begin> Mail-Followup-To: Sergey Bugaev , libc-alpha@sourceware.org, bug-hurd@gnu.org References: <20230423160548.126576-1-bugaevc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230423160548.126576-1-bugaevc@gmail.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Sergey Bugaev, le dim. 23 avril 2023 19:05:45 +0300, a ecrit: > It is of no concern to the receiving process whether or not the sender > process wants to close its copy of sent file descriptor upon exec, and > it should not influence whether or not the received file descriptor gets > the FD_CLOEXEC flag set in the receiving process. > > The latter should in fact be dependent on the MSG_CMSG_CLOEXEC flag > being passed to the recvmsg () call, which is going to be implemented > in the following commit. > > Fixes 344e755248ce02c0f8d095d11cc49e340703d926 > "hurd: Support sending file descriptors over Unix sockets" > > Signed-off-by: Sergey Bugaev > --- > sysdeps/mach/hurd/recvmsg.c | 5 +++-- > sysdeps/mach/hurd/sendmsg.c | 7 +++++-- > 2 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/sysdeps/mach/hurd/recvmsg.c b/sysdeps/mach/hurd/recvmsg.c > index 39de86f6..c08eb499 100644 > --- a/sysdeps/mach/hurd/recvmsg.c > +++ b/sysdeps/mach/hurd/recvmsg.c > @@ -189,7 +189,8 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags) > if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) > { > /* SCM_RIGHTS support. */ > - /* The fd's flags are passed in the control data. */ > + /* The fd's flags are passed in the control data, but there currently > + aren't any defined other than FD_CLOEXEC which we don't respect. */ > int *fds = (int *) CMSG_DATA (cmsg); > nfds = (cmsg->cmsg_len - CMSG_ALIGN (sizeof (struct cmsghdr))) > / sizeof (int); > @@ -200,7 +201,7 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags) > if (err) > goto cleanup; > fds[j] = opened_fds[newfds] = _hurd_intern_fd (newports[newfds], > - fds[j], 0); > + 0, 0); The two patches actually make me realize that there was a confusion here between FD_* flags and O_* flags. _hurd_intern_fd definitely takes O_* flags (and translates O_CLOEXEC to FD_CLOEXEC). If we are to transport some flags, it'd probably rather be O_* flags. I'll commit that way. > if (fds[j] == -1) > { > err = errno; > diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c > index 5871d1d8..2f19797b 100644 > --- a/sysdeps/mach/hurd/sendmsg.c > +++ b/sysdeps/mach/hurd/sendmsg.c > @@ -138,8 +138,11 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) > 0, 0, 0, 0); > if (! err) > nports++; > - /* We pass the flags in the control data. */ > - fds[i] = descriptor->flags; > + /* We pass the file descriptor flags in the control data. > + The only currently defined flag is FD_CLOEXEC, which we > + don't want to pass and so we mask it out, so this will > + always be 0 currently. */ > + fds[i] = descriptor->flags & ~FD_CLOEXEC; > err; > })); > > -- > 2.40.0 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.