diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2025-08-16 10:54:14 +0200 |
---|---|---|
committer | Dimitri Staessens <dimitri@ouroboros.rocks> | 2025-08-23 10:13:33 +0200 |
commit | 575adac4acacf7d02395df0322ff5f03b7b82aaf (patch) | |
tree | f5de69d4f3599f2be0a075b9a9e1af52a9754ad5 /src/irmd/reg/reg.c | |
parent | d0b9463a9e52332b8b0b856d2f9773bbb5d42433 (diff) | |
download | ouroboros-575adac4acacf7d02395df0322ff5f03b7b82aaf.tar.gz ouroboros-575adac4acacf7d02395df0322ff5f03b7b82aaf.zip |
ipcpd: Fix request handling at shutdown
The IPCP states were not entirely correct causing some operations to
be serviced during shutdown. This caused some use-after-free in the
pff. States in the IPCP are now correctly set. IRMd states updated to
the same strategy. The IRMd registry tracks if the IPCP was ENROLLED
or BOOTSTRAPPED, the IPCP just goes to OPERATIONAL.
IPCP state diagram::
NULL -> init() -> INIT -> start() -> BOOT ->
bootstrap/enroll() -> OPERATIONAL -> shutdown()
-> SHUTDOWN -> stop_components() -> BOOT ->
stop() -> INIT -> fini() -> NULL
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Diffstat (limited to 'src/irmd/reg/reg.c')
-rw-r--r-- | src/irmd/reg/reg.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/irmd/reg/reg.c b/src/irmd/reg/reg.c index 0d4c6f24..91385260 100644 --- a/src/irmd/reg/reg.c +++ b/src/irmd/reg/reg.c @@ -732,7 +732,7 @@ int reg_create_ipcp(const struct ipcp_info * info) assert(info != NULL); assert(info->pid != 0); - assert(info->state == IPCP_BOOT); + assert(info->state == IPCP_INIT); pthread_mutex_lock(®.mtx); @@ -1582,8 +1582,7 @@ int reg_set_layer_for_ipcp(struct ipcp_info * info, struct reg_ipcp * ipcp; assert(info != NULL); - assert(info->state > IPCP_BOOT); - assert(info->state < IPCP_SHUTDOWN); + assert(info->state == IPCP_BOOT); pthread_mutex_lock(®.mtx); @@ -2060,7 +2059,7 @@ int reg_wait_ipcp_boot(struct ipcp_info * info, int ret; bool stop = false; - assert(info->state == IPCP_BOOT); + assert(info->state == IPCP_INIT); pthread_mutex_lock(®.mtx); @@ -2080,16 +2079,18 @@ int reg_wait_ipcp_boot(struct ipcp_info * info, ret = -1; stop = true; break; + case IPCP_BOOT: + /* FALLTHRU*/ case IPCP_OPERATIONAL: ret = 0; stop = true; break; - case IPCP_BOOT: + case IPCP_INIT: ret = -__timedwait(®.cond, ®.mtx, abstime); break; default: assert(false); - continue; /* Shut up static analyzer. */ + break; /* Shut up static analyzer. */ } ipcp = __reg_get_ipcp(info->pid); |