kernel: msg: async messages no longer hold a pointer to the thread/port that sent them

this prevents a race condition where an event is sent as a port is being destroyed.
when the server gets around to handling the event, it now refers to a different port
that was created in the mean-time.
This commit is contained in:
2026-03-25 20:19:19 +00:00
parent a0a6a061a4
commit 95d33ddcb9
3 changed files with 22 additions and 9 deletions
+4 -4
View File
@@ -83,8 +83,8 @@ kern_status_t port_connect(struct port *port, struct channel *remote)
msg->msg_status = KMSG_ASYNC;
msg->msg_type = KERN_MSG_TYPE_EVENT;
msg->msg_event = KERN_MSG_EVENT_CONNECTION;
msg->msg_sender_thread = current_thread();
msg->msg_sender_port = port;
msg->msg_sender_thread_id = current_thread()->tr_id;
msg->msg_sender_port_id = port->p_base.ob_id;
unsigned long flags;
channel_lock_irqsave(remote, &flags);
@@ -112,8 +112,8 @@ kern_status_t port_disconnect(struct port *port)
msg->msg_status = KMSG_ASYNC;
msg->msg_type = KERN_MSG_TYPE_EVENT;
msg->msg_event = KERN_MSG_EVENT_DISCONNECTION;
msg->msg_sender_thread = current_thread();
msg->msg_sender_port = port;
msg->msg_sender_thread_id = current_thread()->tr_id;
msg->msg_sender_port_id = port->p_base.ob_id;
unsigned long flags;
channel_lock_irqsave(port->p_remote, &flags);