sched: enforce ref-counting on current task/thread pointers

This commit is contained in:
2026-04-01 18:17:05 +01:00
parent 15c2207ab9
commit 512356ac2d
28 changed files with 364 additions and 103 deletions
+6 -4
View File
@@ -139,7 +139,6 @@ extern kern_status_t channel_recv_msg(
kern_msg_t *out_msg,
unsigned long *irq_flags)
{
struct thread *self = current_thread();
struct msg *msg = NULL;
unsigned long msg_lock_flags;
@@ -170,7 +169,7 @@ extern kern_status_t channel_recv_msg(
}
struct task *sender = msg->msg_sender_thread->tr_parent;
struct task *receiver = self->tr_parent;
struct task *receiver = get_current_task();
struct address_space *src = sender->t_address_space,
*dst = receiver->t_address_space;
@@ -192,6 +191,7 @@ extern kern_status_t channel_recv_msg(
if (status != KERN_OK) {
kmsg_reply_error(msg, status, &msg_lock_flags);
put_current_task(receiver);
return status;
}
@@ -216,6 +216,7 @@ extern kern_status_t channel_recv_msg(
&receiver->t_handles_lock,
f);
address_space_unlock_pair_irqrestore(src, dst, f);
put_current_task(receiver);
if (status != KERN_OK) {
kmsg_reply_error(msg, status, &msg_lock_flags);
@@ -250,11 +251,10 @@ extern kern_status_t channel_reply_msg(
return KERN_INVALID_ARGUMENT;
}
struct thread *self = current_thread();
/* the task that is about to receive the response */
struct task *receiver = msg->msg_sender_thread->tr_parent;
/* the task that is about to send the response */
struct task *sender = self->tr_parent;
struct task *sender = get_current_task();
struct address_space *src = sender->t_address_space,
*dst = receiver->t_address_space;
@@ -275,6 +275,7 @@ extern kern_status_t channel_reply_msg(
if (status != KERN_OK) {
kmsg_reply_error(msg, status, &msg_lock_flags);
put_current_task(sender);
return status;
}
@@ -299,6 +300,7 @@ extern kern_status_t channel_reply_msg(
&receiver->t_handles_lock,
f);
address_space_unlock_pair_irqrestore(src, dst, f);
put_current_task(sender);
if (status != KERN_OK) {
kmsg_reply_error(msg, status, &msg_lock_flags);