From 05e5c1d0745ed5a45cf2801e15434eef3cd4327d Mon Sep 17 00:00:00 2001 From: neil Date: Tue, 6 Nov 2012 03:49:56 +0000 Subject: [PATCH] Protect access to IntExecBase->TaskStorageSlots with Forbid()/Permit() pairs (thanks for the tip, Georg). git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@46008 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/exec/alloctaskstorageslot.c | 6 +++++- rom/exec/freetaskstorageslot.c | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/rom/exec/alloctaskstorageslot.c b/rom/exec/alloctaskstorageslot.c index a8993563bd..04c2ac5307 100644 --- a/rom/exec/alloctaskstorageslot.c +++ b/rom/exec/alloctaskstorageslot.c @@ -47,13 +47,16 @@ { AROS_LIBFUNC_INIT - struct TaskStorageFreeSlot *tsfs = (struct TaskStorageFreeSlot *)GetHead(&PrivExecBase(SysBase)->TaskStorageSlots); + struct TaskStorageFreeSlot *tsfs; LONG slot; struct IntETask *iet = GetIntETask(FindTask(NULL)); if (!iet) return 0; + Forbid(); + tsfs = (struct TaskStorageFreeSlot *) + GetHead(&PrivExecBase(SysBase)->TaskStorageSlots); if (!tsfs) Alert(AT_DeadEnd|AN_MemoryInsane); @@ -71,6 +74,7 @@ Remove((struct Node *) tsfs); FreeMem(tsfs, sizeof(struct TaskStorageFreeSlot)); } + Permit(); return slot; diff --git a/rom/exec/freetaskstorageslot.c b/rom/exec/freetaskstorageslot.c index d1d1c17ea4..0bdfb9aad7 100644 --- a/rom/exec/freetaskstorageslot.c +++ b/rom/exec/freetaskstorageslot.c @@ -27,9 +27,9 @@ None. NOTES - Currently no checks are performed if one is the owner of the slot. - This may be added in the future so one should deallocate a slot - from the same task that allocated the slot. + Currently no checks are performed to determine if one is the owner + of the slot. This may be added in the future, so one should + deallocate a slot from the same task that allocated the slot. EXAMPLE @@ -55,7 +55,9 @@ tsfs->FreeSlot = slot; + Forbid(); AddHead((struct List *)&PrivExecBase(SysBase)->TaskStorageSlots, (struct Node *)tsfs); + Permit(); AROS_LIBFUNC_EXIT } -- 2.11.4.GIT