* [PATCH 6.1.y v2 0/2] nvme-tcp: sanitize request list handling
@ 2026-11-30 0:14 Dickson Wu via B4 Relay
2026-11-30 0:14 ` [PATCH 6.1.y v2 1/2] llist: add interface to check if a node is on a list Dickson Wu via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dickson Wu via B4 Relay @ 2026-11-30 0:14 UTC (permalink / raw)
To: stable
Cc: Hannes Reinecke, Sagi Grimberg, Christoph Hellwig, Keith Busch,
Jens Axboe, linux-nvme
This 6.1.y series replaces v1 at
<20261128-nvme-r2t-61-v1-1-2c1875964e5c@certik.com> per Sasha Levin.
v1 open-coded the llist node helpers; this version backports the llist
prerequisite first and then applies the NVMe/TCP fix in the same form
6.6.y carries, so 6.1.y matches 6.6.y.
Changes in v2:
- Add the llist helper prerequisite as patch 1/2 ("llist: add
interface to check if a node is on a list.") instead of open-coding
init_llist_node() and llist_on_list().
- Apply the NVMe/TCP fix with only the 6.1.y three-argument
nvme_tcp_queue_request() context difference, matching 6.6.y.
---
Hannes Reinecke (1):
nvme-tcp: sanitize request list handling
NeilBrown (1):
llist: add interface to check if a node is on a list.
drivers/nvme/host/tcp.c | 15 ++++++++++++++-
include/linux/llist.h | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 1 deletion(-)
---
base-commit: 1ca1436ccc68275d0b43b6a730b3940fcc46b7c2
change-id: 20261130-nvme-r2t-61v2-4c74a5da2118
Best regards,
--
Dickson Wu <dickson.wu@certik.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 6.1.y v2 1/2] llist: add interface to check if a node is on a list.
2026-11-30 0:14 [PATCH 6.1.y v2 0/2] nvme-tcp: sanitize request list handling Dickson Wu via B4 Relay
@ 2026-11-30 0:14 ` Dickson Wu via B4 Relay
2026-11-30 0:14 ` [PATCH 6.1.y v2 2/2] nvme-tcp: sanitize request list handling Dickson Wu via B4 Relay
2026-12-02 13:48 ` [PATCH 6.1.y v2 0/2] " Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Dickson Wu via B4 Relay @ 2026-11-30 0:14 UTC (permalink / raw)
To: stable
Cc: Hannes Reinecke, Sagi Grimberg, Christoph Hellwig, Keith Busch,
Jens Axboe, linux-nvme
From: NeilBrown <neilb@suse.de>
commit d6b3358a2813bb14791259a2227d9af1e7019ca0 upstream.
With list.h lists, it is easy to test if a node is on a list, providing
it was initialised and that it is removed with list_del_init().
This patch provides similar functionality for llist.h lists.
init_llist_node()
marks a node as being not-on-any-list be setting the ->next pointer to
the node itself.
llist_on_list()
tests if the node is on any list.
llist_del_first_init()
remove the first element from a llist, and marks it as being off-list.
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
---
Clean cherry-pick of the llist helper the next patch relies on.
6.6.y carries it as 604cf76a6a7e.
Tested on 6.1.193: W=1 build of lib/llist.o on base and patched,
no warnings; the patched kernel boots under KVM.
The backport and the test runs were prepared with AI coding tools
(OpenAI Codex agents, with review by Claude). I went over the result
before signing off.
include/linux/llist.h | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/include/linux/llist.h b/include/linux/llist.h
index 85bda2d02d65..dcb91e3bac1c 100644
--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -73,6 +73,33 @@ static inline void init_llist_head(struct llist_head *list)
list->first = NULL;
}
+/**
+ * init_llist_node - initialize lock-less list node
+ * @node: the node to be initialised
+ *
+ * In cases where there is a need to test if a node is on
+ * a list or not, this initialises the node to clearly
+ * not be on any list.
+ */
+static inline void init_llist_node(struct llist_node *node)
+{
+ node->next = node;
+}
+
+/**
+ * llist_on_list - test if a lock-list list node is on a list
+ * @node: the node to test
+ *
+ * When a node is on a list the ->next pointer will be NULL or
+ * some other node. It can never point to itself. We use that
+ * in init_llist_node() to record that a node is not on any list,
+ * and here to test whether it is on any list.
+ */
+static inline bool llist_on_list(const struct llist_node *node)
+{
+ return node->next != node;
+}
+
/**
* llist_entry - get the struct of this entry
* @ptr: the &struct llist_node pointer.
@@ -249,6 +276,21 @@ static inline struct llist_node *__llist_del_all(struct llist_head *head)
extern struct llist_node *llist_del_first(struct llist_head *head);
+/**
+ * llist_del_first_init - delete first entry from lock-list and mark is as being off-list
+ * @head: the head of lock-less list to delete from.
+ *
+ * This behave the same as llist_del_first() except that llist_init_node() is called
+ * on the returned node so that llist_on_list() will report false for the node.
+ */
+static inline struct llist_node *llist_del_first_init(struct llist_head *head)
+{
+ struct llist_node *n = llist_del_first(head);
+
+ if (n)
+ init_llist_node(n);
+ return n;
+}
struct llist_node *llist_reverse_order(struct llist_node *head);
#endif /* LLIST_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 6.1.y v2 2/2] nvme-tcp: sanitize request list handling
2026-11-30 0:14 [PATCH 6.1.y v2 0/2] nvme-tcp: sanitize request list handling Dickson Wu via B4 Relay
2026-11-30 0:14 ` [PATCH 6.1.y v2 1/2] llist: add interface to check if a node is on a list Dickson Wu via B4 Relay
@ 2026-11-30 0:14 ` Dickson Wu via B4 Relay
2026-12-02 13:48 ` [PATCH 6.1.y v2 0/2] " Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Dickson Wu via B4 Relay @ 2026-11-30 0:14 UTC (permalink / raw)
To: stable
Cc: Hannes Reinecke, Sagi Grimberg, Christoph Hellwig, Keith Busch,
Jens Axboe, linux-nvme
From: Hannes Reinecke <hare@kernel.org>
commit 0bf04c874fcb1ae46a863034296e4b33d8fbd66c upstream.
Validate the request in nvme_tcp_handle_r2t() to ensure it's not part of
any list, otherwise a malicious R2T PDU might inject a loop in request
list processing.
Signed-off-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
[ adapted to 6.1.y: async queue_request() has a third argument ]
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
---
Same added and removed lines as upstream; the only context
difference is 6.1.y's three-argument nvme_tcp_queue_request().
6.6.y carries this as 8f27d152b2a5.
Tested on 6.1.193: W=1 build of drivers/nvme/host/tcp.o on base
and patched, no warnings; both kernels boot under KVM and complete
an NVMe/TCP loopback connect, I/O and disconnect.
The backport and the test runs were prepared with AI coding tools
(OpenAI Codex agents, with review by Claude). I went over the result
before signing off.
drivers/nvme/host/tcp.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index d434c24e035d..d9bd7b757d3a 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -386,7 +386,8 @@ nvme_tcp_fetch_request(struct nvme_tcp_queue *queue)
return NULL;
}
- list_del(&req->entry);
+ list_del_init(&req->entry);
+ init_llist_node(&req->lentry);
return req;
}
@@ -494,6 +495,8 @@ static int nvme_tcp_init_request(struct blk_mq_tag_set *set,
req->queue = queue;
nvme_req(rq)->ctrl = &ctrl->ctrl;
nvme_req(rq)->cmd = &pdu->cmd;
+ init_llist_node(&req->lentry);
+ INIT_LIST_HEAD(&req->entry);
return 0;
}
@@ -740,6 +743,14 @@ static int nvme_tcp_handle_r2t(struct nvme_tcp_queue *queue,
return -EPROTO;
}
+ if (llist_on_list(&req->lentry) ||
+ !list_empty(&req->entry)) {
+ dev_err(queue->ctrl->ctrl.device,
+ "req %d unexpected r2t while processing request\n",
+ rq->tag);
+ return -EPROTO;
+ }
+
req->pdu_len = 0;
req->h2cdata_left = r2t_length;
req->h2cdata_offset = r2t_offset;
@@ -2376,6 +2387,8 @@ static void nvme_tcp_submit_async_event(struct nvme_ctrl *arg)
ctrl->async_req.offset = 0;
ctrl->async_req.curr_bio = NULL;
ctrl->async_req.data_len = 0;
+ init_llist_node(&ctrl->async_req.lentry);
+ INIT_LIST_HEAD(&ctrl->async_req.entry);
nvme_tcp_queue_request(&ctrl->async_req, true, true);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 6.1.y v2 0/2] nvme-tcp: sanitize request list handling
2026-11-30 0:14 [PATCH 6.1.y v2 0/2] nvme-tcp: sanitize request list handling Dickson Wu via B4 Relay
2026-11-30 0:14 ` [PATCH 6.1.y v2 1/2] llist: add interface to check if a node is on a list Dickson Wu via B4 Relay
2026-11-30 0:14 ` [PATCH 6.1.y v2 2/2] nvme-tcp: sanitize request list handling Dickson Wu via B4 Relay
@ 2026-12-02 13:48 ` Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-12-02 13:48 UTC (permalink / raw)
To: stable
Cc: Sasha Levin, Hannes Reinecke, Sagi Grimberg, Christoph Hellwig,
Keith Busch, Jens Axboe, linux-nvme, Dickson Wu via B4 Relay,
Dickson Wu
> This 6.1.y series replaces v1 at
> <20261128-nvme-r2t-61-v1-1-2c1875964e5c@certik.com> per Sasha Levin.
Queued the series for 6.1, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-02 13:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 0:14 [PATCH 6.1.y v2 0/2] nvme-tcp: sanitize request list handling Dickson Wu via B4 Relay
2026-11-30 0:14 ` [PATCH 6.1.y v2 1/2] llist: add interface to check if a node is on a list Dickson Wu via B4 Relay
2026-11-30 0:14 ` [PATCH 6.1.y v2 2/2] nvme-tcp: sanitize request list handling Dickson Wu via B4 Relay
2026-12-02 13:48 ` [PATCH 6.1.y v2 0/2] " Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox