Skip to content

Commit ac0648a

Browse files
committed
io_uring: use bottom half safe lock for fixed file data
io_file_data_ref_zero() can be invoked from soft-irq from the RCU core, hence we need to ensure that the file_data lock is bottom half safe. Use the _bh() variants when grabbing this lock. Reported-by: [email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent bd5bbda commit ac0648a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/io_uring.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7185,9 +7185,9 @@ static int io_sqe_files_unregister(struct io_ring_ctx *ctx)
71857185
if (!data)
71867186
return -ENXIO;
71877187

7188-
spin_lock(&data->lock);
7188+
spin_lock_bh(&data->lock);
71897189
ref_node = data->node;
7190-
spin_unlock(&data->lock);
7190+
spin_unlock_bh(&data->lock);
71917191
if (ref_node)
71927192
percpu_ref_kill(&ref_node->refs);
71937193

@@ -7569,7 +7569,7 @@ static void io_file_data_ref_zero(struct percpu_ref *ref)
75697569
data = ref_node->file_data;
75707570
ctx = data->ctx;
75717571

7572-
spin_lock(&data->lock);
7572+
spin_lock_bh(&data->lock);
75737573
ref_node->done = true;
75747574

75757575
while (!list_empty(&data->ref_list)) {
@@ -7581,7 +7581,7 @@ static void io_file_data_ref_zero(struct percpu_ref *ref)
75817581
list_del(&ref_node->node);
75827582
first_add |= llist_add(&ref_node->llist, &ctx->file_put_llist);
75837583
}
7584-
spin_unlock(&data->lock);
7584+
spin_unlock_bh(&data->lock);
75857585

75867586
if (percpu_ref_is_dying(&data->refs))
75877587
delay = 0;
@@ -7704,9 +7704,9 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
77047704
}
77057705

77067706
file_data->node = ref_node;
7707-
spin_lock(&file_data->lock);
7707+
spin_lock_bh(&file_data->lock);
77087708
list_add_tail(&ref_node->node, &file_data->ref_list);
7709-
spin_unlock(&file_data->lock);
7709+
spin_unlock_bh(&file_data->lock);
77107710
percpu_ref_get(&file_data->refs);
77117711
return ret;
77127712
out_fput:
@@ -7863,10 +7863,10 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
78637863

78647864
if (needs_switch) {
78657865
percpu_ref_kill(&data->node->refs);
7866-
spin_lock(&data->lock);
7866+
spin_lock_bh(&data->lock);
78677867
list_add_tail(&ref_node->node, &data->ref_list);
78687868
data->node = ref_node;
7869-
spin_unlock(&data->lock);
7869+
spin_unlock_bh(&data->lock);
78707870
percpu_ref_get(&ctx->file_data->refs);
78717871
} else
78727872
destroy_fixed_file_ref_node(ref_node);

0 commit comments

Comments
 (0)