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 97D1D3858C39 for ; Mon, 24 Apr 2023 21:10:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97D1D3858C39 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 1pr3Rt-0002CF-31; Mon, 24 Apr 2023 17:10:13 -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=UJ7tA2MLd4wm8UMe3nW/sFysSs3zMvgYw1uGYHHsuPM=; b=O+HU7187QARZnXZoTvhJ trCcNseSgkV3/5yXoFWiL9jZ2uWQ2ZsNGToaf4UXoBrtRz0fIQPul7P4F24EB/kJ5S+iHtrHw9dZy Z5H16cxnaxIo2VzrlGBsvjh3eh174tdENYyOCreIuV+HUTp7S9ZekY4okzavE9TcDeLkExEzPMds9 Kj0alOfW2MCyQS4sSxkKuieUSVXSfPziwO22JRtXglmbksNm9/HgLPV6eE3450tPpuwYzQdpb7sm7 RHF9ohhT4DJRUEROAq5yhh3tNDG63j4rWDrZapnCSzy2d/RA3rppyCjKOiijre7TsH+Cfgptwy/a+ Am7A4gYQcvvYoQ==; 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 1pr3Rs-0001a3-3i; Mon, 24 Apr 2023 17:10:12 -0400 Received: from samy by begin.home with local (Exim 4.96) (envelope-from ) id 1pr3Rp-003ugo-2d; Mon, 24 Apr 2023 23:10:09 +0200 Date: Mon, 24 Apr 2023 23:10:09 +0200 From: Samuel Thibault To: Sergey Bugaev Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: Re: [PATCH v2 2/4] hurd: Implement MSG_CMSG_CLOEXEC Message-ID: <20230424211009.3dbv745qz36vmkpi@begin> Mail-Followup-To: Sergey Bugaev , libc-alpha@sourceware.org, bug-hurd@gnu.org References: <20230423160548.126576-1-bugaevc@gmail.com> <20230423160548.126576-2-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-2-bugaevc@gmail.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-12.3 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: Applied, thanks! Sergey Bugaev, le dim. 23 avril 2023 19:05:46 +0300, a ecrit: > This is a new flag that can be passed to recvmsg () to make it > atomically set the CLOEXEC flag on all the file descriptors received > using the SCM_RIGHTS mechanism. This is useful for all the same reasons > that the other XXX_CLOEXEC flags are useful: namely, it provides > atomicity with respect to another thread of the same process calling > (fork and then) exec at the same time. > > This flag is already supported on Linux and FreeBSD. The flag's value, > 0x40000, is choosen to match FreeBSD's. > > Signed-off-by: Sergey Bugaev > --- > sysdeps/mach/hurd/bits/socket.h | 5 ++++- > sysdeps/mach/hurd/recvmsg.c | 3 ++- > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h > index 2d78a916..c2392bed 100644 > --- a/sysdeps/mach/hurd/bits/socket.h > +++ b/sysdeps/mach/hurd/bits/socket.h > @@ -197,8 +197,11 @@ enum > #define MSG_WAITALL MSG_WAITALL > MSG_DONTWAIT = 0x80, /* This message should be nonblocking. */ > #define MSG_DONTWAIT MSG_DONTWAIT > - MSG_NOSIGNAL = 0x0400 /* Do not generate SIGPIPE on EPIPE. */ > + MSG_NOSIGNAL = 0x0400, /* Do not generate SIGPIPE on EPIPE. */ > #define MSG_NOSIGNAL MSG_NOSIGNAL > + MSG_CMSG_CLOEXEC = 0x40000 /* Atomically set close-on-exec flag > + for file descriptors in SCM_RIGHTS. */ > +#define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC > }; > > > diff --git a/sysdeps/mach/hurd/recvmsg.c b/sysdeps/mach/hurd/recvmsg.c > index c08eb499..9a37a053 100644 > --- a/sysdeps/mach/hurd/recvmsg.c > +++ b/sysdeps/mach/hurd/recvmsg.c > @@ -197,11 +197,12 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags) > > for (j = 0; j < nfds; j++) > { > + int fd_flags = (flags & MSG_CMSG_CLOEXEC) ? O_CLOEXEC : 0; > err = reauthenticate (ports[i], &newports[newfds]); > if (err) > goto cleanup; > fds[j] = opened_fds[newfds] = _hurd_intern_fd (newports[newfds], > - 0, 0); > + fd_flags, 0); > if (fds[j] == -1) > { > err = errno; > -- > 2.40.0 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.