From 2d5b708ff6222775aed3dca87ac094aedc0b7571 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Wed, 15 Jun 2022 21:44:57 +0200 Subject: [PATCH] copy: safeguard advance on concluded states --- kernel/mars_copy.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/mars_copy.c b/kernel/mars_copy.c index 427d518e..d1079fcb 100644 --- a/kernel/mars_copy.c +++ b/kernel/mars_copy.c @@ -846,6 +846,7 @@ int _run_copy(struct copy_brick *brick, loff_t this_start) unsigned len; unsigned index = GET_INDEX(pos); struct copy_state *st = &GET_STATE(brick, index); + bool is_active; if (st->state != COPY_STATE_FINISHED) { break; @@ -870,6 +871,16 @@ int _run_copy(struct copy_brick *brick, loff_t this_start) } break; } + is_active = + (READ_ONCE(st->active[0]) | + READ_ONCE(st->active[1])) != 0; + if (is_active) { + break; + } + if (READ_ONCE(st->table[0]) || + READ_ONCE(st->table[1])) { + break; + } // rollover st->state = COPY_STATE_START; len = st->len;