Skip to content

Commit 0136d86

Browse files
committed
Merge tag 'block-6.2-2023-02-03' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: "A bit bigger than I'd like at this point, but mostly a bunch of little fixes. In detail: - NVMe pull request via Christoph: - Fix a missing queue put in nvmet_fc_ls_create_association (Amit Engel) - Clear queue pointers on tag_set initialization failure (Maurizio Lombardi) - Use workqueue dedicated to authentication (Shin'ichiro Kawasaki) - Fix for an overflow in ublk (Liu) - Fix for leaking a queue reference in block cgroups (Ming) - Fix for a use-after-free in BFQ (Yu)" * tag 'block-6.2-2023-02-03' of git://git.kernel.dk/linux: blk-cgroup: don't update io stat for root cgroup nvme-auth: use workqueue dedicated to authentication nvme: clear the request_queue pointers on failure in nvme_alloc_io_tag_set nvme: clear the request_queue pointers on failure in nvme_alloc_admin_tag_set nvme-fc: fix a missing queue put in nvmet_fc_ls_create_association block: Fix the blk_mq_destroy_queue() documentation block: ublk: extending queue_size to fix overflow block, bfq: fix uaf for bfqq in bic_set_bfqq()
2 parents 7b753a9 + e02bbac commit 0136d86

File tree

8 files changed

+31
-9
lines changed

8 files changed

+31
-9
lines changed

block/bfq-cgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,8 @@ static void __bfq_bic_change_cgroup(struct bfq_data *bfqd,
769769
* request from the old cgroup.
770770
*/
771771
bfq_put_cooperator(sync_bfqq);
772-
bfq_release_process_ref(bfqd, sync_bfqq);
773772
bic_set_bfqq(bic, NULL, true);
773+
bfq_release_process_ref(bfqd, sync_bfqq);
774774
}
775775
}
776776
}

block/bfq-iosched.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5425,9 +5425,11 @@ static void bfq_check_ioprio_change(struct bfq_io_cq *bic, struct bio *bio)
54255425

54265426
bfqq = bic_to_bfqq(bic, false);
54275427
if (bfqq) {
5428-
bfq_release_process_ref(bfqd, bfqq);
5428+
struct bfq_queue *old_bfqq = bfqq;
5429+
54295430
bfqq = bfq_get_queue(bfqd, bio, false, bic, true);
54305431
bic_set_bfqq(bic, bfqq, false);
5432+
bfq_release_process_ref(bfqd, old_bfqq);
54315433
}
54325434

54335435
bfqq = bic_to_bfqq(bic, true);

block/blk-cgroup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,10 @@ void blk_cgroup_bio_start(struct bio *bio)
20012001
struct blkg_iostat_set *bis;
20022002
unsigned long flags;
20032003

2004+
/* Root-level stats are sourced from system-wide IO stats */
2005+
if (!cgroup_parent(blkcg->css.cgroup))
2006+
return;
2007+
20042008
cpu = get_cpu();
20052009
bis = per_cpu_ptr(bio->bi_blkg->iostat_cpu, cpu);
20062010
flags = u64_stats_update_begin_irqsave(&bis->sync);

block/blk-mq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4069,8 +4069,9 @@ EXPORT_SYMBOL(blk_mq_init_queue);
40694069
* blk_mq_destroy_queue - shutdown a request queue
40704070
* @q: request queue to shutdown
40714071
*
4072-
* This shuts down a request queue allocated by blk_mq_init_queue() and drops
4073-
* the initial reference. All future requests will failed with -ENODEV.
4072+
* This shuts down a request queue allocated by blk_mq_init_queue(). All future
4073+
* requests will be failed with -ENODEV. The caller is responsible for dropping
4074+
* the reference from blk_mq_init_queue() by calling blk_put_queue().
40744075
*
40754076
* Context: can sleep
40764077
*/

drivers/block/ublk_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ struct ublk_device {
137137

138138
char *__queues;
139139

140-
unsigned short queue_size;
140+
unsigned int queue_size;
141141
struct ublksrv_ctrl_dev_info dev_info;
142142

143143
struct blk_mq_tag_set tag_set;

drivers/nvme/host/auth.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ struct nvme_dhchap_queue_context {
4545
int sess_key_len;
4646
};
4747

48+
struct workqueue_struct *nvme_auth_wq;
49+
4850
#define nvme_auth_flags_from_qid(qid) \
4951
(qid == 0) ? 0 : BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_RESERVED
5052
#define nvme_auth_queue_from_qid(ctrl, qid) \
@@ -866,7 +868,7 @@ int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid)
866868

867869
chap = &ctrl->dhchap_ctxs[qid];
868870
cancel_work_sync(&chap->auth_work);
869-
queue_work(nvme_wq, &chap->auth_work);
871+
queue_work(nvme_auth_wq, &chap->auth_work);
870872
return 0;
871873
}
872874
EXPORT_SYMBOL_GPL(nvme_auth_negotiate);
@@ -1008,10 +1010,15 @@ EXPORT_SYMBOL_GPL(nvme_auth_free);
10081010

10091011
int __init nvme_init_auth(void)
10101012
{
1013+
nvme_auth_wq = alloc_workqueue("nvme-auth-wq",
1014+
WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0);
1015+
if (!nvme_auth_wq)
1016+
return -ENOMEM;
1017+
10111018
nvme_chap_buf_cache = kmem_cache_create("nvme-chap-buf-cache",
10121019
CHAP_BUF_SIZE, 0, SLAB_HWCACHE_ALIGN, NULL);
10131020
if (!nvme_chap_buf_cache)
1014-
return -ENOMEM;
1021+
goto err_destroy_workqueue;
10151022

10161023
nvme_chap_buf_pool = mempool_create(16, mempool_alloc_slab,
10171024
mempool_free_slab, nvme_chap_buf_cache);
@@ -1021,11 +1028,14 @@ int __init nvme_init_auth(void)
10211028
return 0;
10221029
err_destroy_chap_buf_cache:
10231030
kmem_cache_destroy(nvme_chap_buf_cache);
1031+
err_destroy_workqueue:
1032+
destroy_workqueue(nvme_auth_wq);
10241033
return -ENOMEM;
10251034
}
10261035

10271036
void __exit nvme_exit_auth(void)
10281037
{
10291038
mempool_destroy(nvme_chap_buf_pool);
10301039
kmem_cache_destroy(nvme_chap_buf_cache);
1040+
destroy_workqueue(nvme_auth_wq);
10311041
}

drivers/nvme/host/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4921,7 +4921,9 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
49214921
blk_mq_destroy_queue(ctrl->admin_q);
49224922
blk_put_queue(ctrl->admin_q);
49234923
out_free_tagset:
4924-
blk_mq_free_tag_set(ctrl->admin_tagset);
4924+
blk_mq_free_tag_set(set);
4925+
ctrl->admin_q = NULL;
4926+
ctrl->fabrics_q = NULL;
49254927
return ret;
49264928
}
49274929
EXPORT_SYMBOL_GPL(nvme_alloc_admin_tag_set);
@@ -4983,6 +4985,7 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
49834985

49844986
out_free_tag_set:
49854987
blk_mq_free_tag_set(set);
4988+
ctrl->connect_q = NULL;
49864989
return ret;
49874990
}
49884991
EXPORT_SYMBOL_GPL(nvme_alloc_io_tag_set);

drivers/nvme/target/fc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,8 +1685,10 @@ nvmet_fc_ls_create_association(struct nvmet_fc_tgtport *tgtport,
16851685
else {
16861686
queue = nvmet_fc_alloc_target_queue(iod->assoc, 0,
16871687
be16_to_cpu(rqst->assoc_cmd.sqsize));
1688-
if (!queue)
1688+
if (!queue) {
16891689
ret = VERR_QUEUE_ALLOC_FAIL;
1690+
nvmet_fc_tgt_a_put(iod->assoc);
1691+
}
16901692
}
16911693
}
16921694

0 commit comments

Comments
 (0)