diff mbox series

[5/5] hurd: Avoid leaking task & thread ports

Message ID 20230414193700.542116-5-bugaevc@gmail.com
State New
Headers show
Series [1/5] hurd: Fix restoring reply port in sigreturn | expand

Commit Message

Sergey Bugaev April 14, 2023, 7:37 p.m. UTC
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
 hurd/catch-exc.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Samuel Thibault April 17, 2023, 11:24 p.m. UTC | #1
Applied, thanks!

Sergey Bugaev, le ven. 14 avril 2023 22:37:00 +0300, a ecrit:
> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
> ---
>  hurd/catch-exc.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/hurd/catch-exc.c b/hurd/catch-exc.c
> index d375bf67..bec850f9 100644
> --- a/hurd/catch-exc.c
> +++ b/hurd/catch-exc.c
> @@ -35,6 +35,7 @@ _S_catch_exception_raise (mach_port_t port,
>  #endif
>  			  )
>  {
> +  error_t err;
>    struct hurd_sigstate *ss;
>    int signo;
>    struct hurd_signal_detail d;
> @@ -83,6 +84,11 @@ _S_catch_exception_raise (mach_port_t port,
>  			      MACH_PORT_NULL, MACH_MSG_TYPE_PORT_SEND,
>  			      0);
>  
> +  err = __mach_port_deallocate (__mach_task_self (), task);
> +  assert_perror (err);
> +  err = __mach_port_deallocate (__mach_task_self (), thread);
> +  assert_perror (err);
> +
>    return KERN_SUCCESS;
>  }
>  
> -- 
> 2.39.2
>
diff mbox series

Patch

diff --git a/hurd/catch-exc.c b/hurd/catch-exc.c
index d375bf67..bec850f9 100644
--- a/hurd/catch-exc.c
+++ b/hurd/catch-exc.c
@@ -35,6 +35,7 @@  _S_catch_exception_raise (mach_port_t port,
 #endif
 			  )
 {
+  error_t err;
   struct hurd_sigstate *ss;
   int signo;
   struct hurd_signal_detail d;
@@ -83,6 +84,11 @@  _S_catch_exception_raise (mach_port_t port,
 			      MACH_PORT_NULL, MACH_MSG_TYPE_PORT_SEND,
 			      0);
 
+  err = __mach_port_deallocate (__mach_task_self (), task);
+  assert_perror (err);
+  err = __mach_port_deallocate (__mach_task_self (), thread);
+  assert_perror (err);
+
   return KERN_SUCCESS;
 }