Skip to content

Commit 9ebc0ec

Browse files
committed
Merge tag 'block-6.0-2022-09-09' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - NVMe pull via Christoph: - fix a use after free in nvmet (Bart Van Assche) - fix a use after free when detecting digest errors (Sagi Grimberg) - fix regression that causes sporadic TCP requests to time out (Sagi Grimberg) - fix two off by ones errors in the nvmet ZNS support (Dennis Maisenbacher) - requeue aen after firmware activation (Keith Busch) - Fix missing request flags in debugfs code (me) - Partition scan fix (Ming) * tag 'block-6.0-2022-09-09' of git://git.kernel.dk/linux-block: block: add missing request flags to debugfs code nvme: requeue aen after firmware activation nvmet: fix mar and mor off-by-one errors nvme-tcp: fix regression that causes sporadic requests to time out nvme-tcp: fix UAF when detecting digest errors nvmet: fix a use-after-free block: don't add partitions if GD_SUPPRESS_PART_SCAN is set
2 parents d2b768c + 745ed37 commit 9ebc0ec

File tree

6 files changed

+37
-12
lines changed

6 files changed

+37
-12
lines changed

block/blk-mq-debugfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ static const char *const rqf_name[] = {
283283
RQF_NAME(SPECIAL_PAYLOAD),
284284
RQF_NAME(ZONE_WRITE_LOCKED),
285285
RQF_NAME(MQ_POLL_SLEPT),
286+
RQF_NAME(TIMED_OUT),
286287
RQF_NAME(ELV),
288+
RQF_NAME(RESV),
287289
};
288290
#undef RQF_NAME
289291

block/partitions/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,9 @@ static int blk_add_partitions(struct gendisk *disk)
596596
if (disk->flags & GENHD_FL_NO_PART)
597597
return 0;
598598

599+
if (test_bit(GD_SUPPRESS_PART_SCAN, &disk->state))
600+
return 0;
601+
599602
state = check_partition(disk);
600603
if (!state)
601604
return 0;

drivers/nvme/host/core.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4703,6 +4703,8 @@ static void nvme_fw_act_work(struct work_struct *work)
47034703
nvme_start_queues(ctrl);
47044704
/* read FW slot information to clear the AER */
47054705
nvme_get_fw_slot_info(ctrl);
4706+
4707+
queue_work(nvme_wq, &ctrl->async_event_work);
47064708
}
47074709

47084710
static u32 nvme_aer_type(u32 result)
@@ -4715,9 +4717,10 @@ static u32 nvme_aer_subtype(u32 result)
47154717
return (result & 0xff00) >> 8;
47164718
}
47174719

4718-
static void nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)
4720+
static bool nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)
47194721
{
47204722
u32 aer_notice_type = nvme_aer_subtype(result);
4723+
bool requeue = true;
47214724

47224725
trace_nvme_async_event(ctrl, aer_notice_type);
47234726

@@ -4734,6 +4737,7 @@ static void nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)
47344737
*/
47354738
if (nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING)) {
47364739
nvme_auth_stop(ctrl);
4740+
requeue = false;
47374741
queue_work(nvme_wq, &ctrl->fw_act_work);
47384742
}
47394743
break;
@@ -4750,6 +4754,7 @@ static void nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)
47504754
default:
47514755
dev_warn(ctrl->device, "async event result %08x\n", result);
47524756
}
4757+
return requeue;
47534758
}
47544759

47554760
static void nvme_handle_aer_persistent_error(struct nvme_ctrl *ctrl)
@@ -4765,13 +4770,14 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
47654770
u32 result = le32_to_cpu(res->u32);
47664771
u32 aer_type = nvme_aer_type(result);
47674772
u32 aer_subtype = nvme_aer_subtype(result);
4773+
bool requeue = true;
47684774

47694775
if (le16_to_cpu(status) >> 1 != NVME_SC_SUCCESS)
47704776
return;
47714777

47724778
switch (aer_type) {
47734779
case NVME_AER_NOTICE:
4774-
nvme_handle_aen_notice(ctrl, result);
4780+
requeue = nvme_handle_aen_notice(ctrl, result);
47754781
break;
47764782
case NVME_AER_ERROR:
47774783
/*
@@ -4792,7 +4798,9 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
47924798
default:
47934799
break;
47944800
}
4795-
queue_work(nvme_wq, &ctrl->async_event_work);
4801+
4802+
if (requeue)
4803+
queue_work(nvme_wq, &ctrl->async_event_work);
47964804
}
47974805
EXPORT_SYMBOL_GPL(nvme_complete_async_event);
47984806

drivers/nvme/host/tcp.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ struct nvme_tcp_queue {
121121
struct mutex send_mutex;
122122
struct llist_head req_list;
123123
struct list_head send_list;
124-
bool more_requests;
125124

126125
/* recv state */
127126
void *pdu;
@@ -320,7 +319,7 @@ static inline void nvme_tcp_send_all(struct nvme_tcp_queue *queue)
320319
static inline bool nvme_tcp_queue_more(struct nvme_tcp_queue *queue)
321320
{
322321
return !list_empty(&queue->send_list) ||
323-
!llist_empty(&queue->req_list) || queue->more_requests;
322+
!llist_empty(&queue->req_list);
324323
}
325324

326325
static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,
@@ -339,9 +338,7 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,
339338
*/
340339
if (queue->io_cpu == raw_smp_processor_id() &&
341340
sync && empty && mutex_trylock(&queue->send_mutex)) {
342-
queue->more_requests = !last;
343341
nvme_tcp_send_all(queue);
344-
queue->more_requests = false;
345342
mutex_unlock(&queue->send_mutex);
346343
}
347344

@@ -1229,7 +1226,7 @@ static void nvme_tcp_io_work(struct work_struct *w)
12291226
else if (unlikely(result < 0))
12301227
return;
12311228

1232-
if (!pending)
1229+
if (!pending || !queue->rd_enabled)
12331230
return;
12341231

12351232
} while (!time_after(jiffies, deadline)); /* quota is exhausted */

drivers/nvme/target/core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ static void nvmet_set_error(struct nvmet_req *req, u16 status)
735735

736736
static void __nvmet_req_complete(struct nvmet_req *req, u16 status)
737737
{
738+
struct nvmet_ns *ns = req->ns;
739+
738740
if (!req->sq->sqhd_disabled)
739741
nvmet_update_sq_head(req);
740742
req->cqe->sq_id = cpu_to_le16(req->sq->qid);
@@ -745,9 +747,9 @@ static void __nvmet_req_complete(struct nvmet_req *req, u16 status)
745747

746748
trace_nvmet_req_complete(req);
747749

748-
if (req->ns)
749-
nvmet_put_namespace(req->ns);
750750
req->ops->queue_response(req);
751+
if (ns)
752+
nvmet_put_namespace(ns);
751753
}
752754

753755
void nvmet_req_complete(struct nvmet_req *req, u16 status)

drivers/nvme/target/zns.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
100100
struct nvme_id_ns_zns *id_zns;
101101
u64 zsze;
102102
u16 status;
103+
u32 mar, mor;
103104

104105
if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) {
105106
req->error_loc = offsetof(struct nvme_identify, nsid);
@@ -130,8 +131,20 @@ void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
130131
zsze = (bdev_zone_sectors(req->ns->bdev) << 9) >>
131132
req->ns->blksize_shift;
132133
id_zns->lbafe[0].zsze = cpu_to_le64(zsze);
133-
id_zns->mor = cpu_to_le32(bdev_max_open_zones(req->ns->bdev));
134-
id_zns->mar = cpu_to_le32(bdev_max_active_zones(req->ns->bdev));
134+
135+
mor = bdev_max_open_zones(req->ns->bdev);
136+
if (!mor)
137+
mor = U32_MAX;
138+
else
139+
mor--;
140+
id_zns->mor = cpu_to_le32(mor);
141+
142+
mar = bdev_max_active_zones(req->ns->bdev);
143+
if (!mar)
144+
mar = U32_MAX;
145+
else
146+
mar--;
147+
id_zns->mar = cpu_to_le32(mar);
135148

136149
done:
137150
status = nvmet_copy_to_sgl(req, 0, id_zns, sizeof(*id_zns));

0 commit comments

Comments
 (0)