Skip to content

Commit 1d0e850

Browse files
committed
afs: Fix cell removal
Fix cell removal by inserting a more final state than AFS_CELL_FAILED that indicates that the cell has been unpublished in case the manager is already requeued and will go through again. The new AFS_CELL_REMOVED state will just immediately leave the manager function. Going through a second time in the AFS_CELL_FAILED state will cause it to try to remove the cell again, potentially leading to the proc list being removed. Fixes: 989782d ("afs: Overhaul cell database management") Reported-by: syzbot+b994ecf2b023f14832c1@syzkaller.appspotmail.com Reported-by: syzbot+0e0db88e1eb44a91ae8d@syzkaller.appspotmail.com Reported-by: syzbot+2d0585e5efcd43d113c2@syzkaller.appspotmail.com Reported-by: syzbot+1ecc2f9d3387f1d79d42@syzkaller.appspotmail.com Reported-by: syzbot+18d51774588492bf3f69@syzkaller.appspotmail.com Reported-by: syzbot+a5e4946b04d6ca8fa5f3@syzkaller.appspotmail.com Suggested-by: Hillf Danton <hdanton@sina.com> Signed-off-by: David Howells <dhowells@redhat.com> cc: Hillf Danton <hdanton@sina.com>
1 parent 286377f commit 1d0e850

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

fs/afs/cell.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,11 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,
291291
wait_var_event(&cell->state,
292292
({
293293
state = smp_load_acquire(&cell->state); /* vs error */
294-
state == AFS_CELL_ACTIVE || state == AFS_CELL_FAILED;
294+
state == AFS_CELL_ACTIVE || state == AFS_CELL_REMOVED;
295295
}));
296296

297297
/* Check the state obtained from the wait check. */
298-
if (state == AFS_CELL_FAILED) {
298+
if (state == AFS_CELL_REMOVED) {
299299
ret = cell->error;
300300
goto error;
301301
}
@@ -700,7 +700,6 @@ static void afs_deactivate_cell(struct afs_net *net, struct afs_cell *cell)
700700
static void afs_manage_cell(struct afs_cell *cell)
701701
{
702702
struct afs_net *net = cell->net;
703-
bool deleted;
704703
int ret, active;
705704

706705
_enter("%s", cell->name);
@@ -712,13 +711,15 @@ static void afs_manage_cell(struct afs_cell *cell)
712711
case AFS_CELL_FAILED:
713712
down_write(&net->cells_lock);
714713
active = 1;
715-
deleted = atomic_try_cmpxchg_relaxed(&cell->active, &active, 0);
716-
if (deleted) {
714+
if (atomic_try_cmpxchg_relaxed(&cell->active, &active, 0)) {
717715
rb_erase(&cell->net_node, &net->cells);
716+
smp_store_release(&cell->state, AFS_CELL_REMOVED);
718717
}
719718
up_write(&net->cells_lock);
720-
if (deleted)
719+
if (cell->state == AFS_CELL_REMOVED) {
720+
wake_up_var(&cell->state);
721721
goto final_destruction;
722+
}
722723
if (cell->state == AFS_CELL_FAILED)
723724
goto done;
724725
smp_store_release(&cell->state, AFS_CELL_UNSET);
@@ -760,6 +761,9 @@ static void afs_manage_cell(struct afs_cell *cell)
760761
wake_up_var(&cell->state);
761762
goto again;
762763

764+
case AFS_CELL_REMOVED:
765+
goto done;
766+
763767
default:
764768
break;
765769
}

fs/afs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ enum afs_cell_state {
326326
AFS_CELL_DEACTIVATING,
327327
AFS_CELL_INACTIVE,
328328
AFS_CELL_FAILED,
329+
AFS_CELL_REMOVED,
329330
};
330331

331332
/*

0 commit comments

Comments
 (0)