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 C9D9C3858D1E for ; Mon, 24 Apr 2023 20:44:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9D9C3858D1E 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 1pr335-0001xR-BO; Mon, 24 Apr 2023 16:44:35 -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=JcFueYugtYoDB+RhlBHUXcdXPow5F5j3uibqEKJZaJ8=; b=QRrTCZxGGIVaX8gjua0F V8vQZjKuxIf3GGkPQmfD5TDrlSpkPsCJoyzlCScvMyx7n9lVdoJMjzgmC3YbnChFkjQDWjP5+PR2j +gOsf3g73R6audsqn3iY2Ec+qzH/FtJTljeSKhWt6D/lWoQvxzjJcWIcdhUAJaJgvmbezVXRlnOuS IPhMocL98eFTXtETNs984dUhZCCS+q9aMvwvFlIb0KzuZimP+E7VvX7rSi3Dyrgyp/LYxcHT3sQO5 fwh8J3WKRCrw/HRIrkPdsOYxDlzXeQOfaTVqWn2KWP7bNO5U8VhzgxheaRLHFYGuG/p9clfQPSlo5 PnYux0/Nir48dw==; 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 1pr334-0003Dn-Ec; Mon, 24 Apr 2023 16:44:35 -0400 Received: from samy by begin.home with local (Exim 4.96) (envelope-from ) id 1pr331-003tpN-32; Mon, 24 Apr 2023 22:44:31 +0200 Date: Mon, 24 Apr 2023 22:44:31 +0200 From: Samuel Thibault To: Sergey Bugaev Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: Re: [PATCH v2 3/4] hurd: Only deallocate addrport when it's valid Message-ID: <20230424204431.c36u3etfo63ns7n7@begin> Mail-Followup-To: Sergey Bugaev , libc-alpha@sourceware.org, bug-hurd@gnu.org References: <20230423160548.126576-1-bugaevc@gmail.com> <20230423160548.126576-3-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-3-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: Applied, thanks! Sergey Bugaev, le dim. 23 avril 2023 19:05:47 +0300, a ecrit: > Signed-off-by: Sergey Bugaev > --- > sysdeps/mach/hurd/recv.c | 3 ++- > sysdeps/mach/hurd/recvfrom.c | 3 ++- > sysdeps/mach/hurd/recvmsg.c | 3 ++- > sysdeps/mach/hurd/sendmsg.c | 5 +++-- > sysdeps/mach/hurd/sendto.c | 2 +- > 5 files changed, 10 insertions(+), 6 deletions(-) > > diff --git a/sysdeps/mach/hurd/recv.c b/sysdeps/mach/hurd/recv.c > index 3bd5c16f..1783e38d 100644 > --- a/sysdeps/mach/hurd/recv.c > +++ b/sysdeps/mach/hurd/recv.c > @@ -54,7 +54,8 @@ __recv (int fd, void *buf, size_t n, int flags) > if (err) > return __hurd_sockfail (fd, flags, err); > > - __mach_port_deallocate (__mach_task_self (), addrport); > + if (MACH_PORT_VALID (addrport)) > + __mach_port_deallocate (__mach_task_self (), addrport); > __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen); > > if (bufp != buf) > diff --git a/sysdeps/mach/hurd/recvfrom.c b/sysdeps/mach/hurd/recvfrom.c > index 1cd5f917..6f2c927a 100644 > --- a/sysdeps/mach/hurd/recvfrom.c > +++ b/sysdeps/mach/hurd/recvfrom.c > @@ -94,7 +94,8 @@ __recvfrom (int fd, void *buf, size_t n, int flags, __SOCKADDR_ARG addrarg, > else if (addr_len != NULL) > *addr_len = 0; > > - __mach_port_deallocate (__mach_task_self (), addrport); > + if (MACH_PORT_VALID (addrport)) > + __mach_port_deallocate (__mach_task_self (), addrport); > > /* Toss control data; we don't care. */ > __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen); > diff --git a/sysdeps/mach/hurd/recvmsg.c b/sysdeps/mach/hurd/recvmsg.c > index 9a37a053..9cf3de48 100644 > --- a/sysdeps/mach/hurd/recvmsg.c > +++ b/sysdeps/mach/hurd/recvmsg.c > @@ -135,7 +135,8 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags) > else if (message->msg_name != NULL) > message->msg_namelen = 0; > > - __mach_port_deallocate (__mach_task_self (), aport); > + if (MACH_PORT_VALID (aport)) > + __mach_port_deallocate (__mach_task_self (), aport); > > if (buf == data) > buf += len; > diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c > index 2f19797b..f9ad7699 100644 > --- a/sysdeps/mach/hurd/sendmsg.c > +++ b/sysdeps/mach/hurd/sendmsg.c > @@ -198,8 +198,9 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) > message->msg_controllen, > &amount); > LIBC_CANCEL_RESET (cancel_oldtype); > - __mach_port_deallocate (__mach_task_self (), > - aport); > + if (MACH_PORT_VALID (aport)) > + __mach_port_deallocate (__mach_task_self (), > + aport); > } > err; > })); > diff --git a/sysdeps/mach/hurd/sendto.c b/sysdeps/mach/hurd/sendto.c > index 5a960de8..777af1c4 100644 > --- a/sysdeps/mach/hurd/sendto.c > +++ b/sysdeps/mach/hurd/sendto.c > @@ -94,7 +94,7 @@ __sendto (int fd, > err; > })); > > - if (aport != MACH_PORT_NULL) > + if (MACH_PORT_VALID (aport)) > __mach_port_deallocate (__mach_task_self (), aport); > > return err ? __hurd_sockfail (fd, flags, err) : wrote; > -- > 2.40.0 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.