CVE-2025-38264: backport fix series
Subsystems (2)
cover CVE-2025-38264: backport fix series
Hi,
Please consider this backport series for CVE-2025-38264 to 6.6.y.
Apply the patches in this order:
1. llist: add interface to check if a node is on a list. (prerequisite)
2. nvme-tcp: sanitize request list handling (fix)
Patch 1 adds llist helpers to mark an unused node, test its membership, and restore the unused state after dequeue.
Patch 2 initializes and resets NVMe/TCP request-list membership and rejects R2T processing while the request remains queued. The code changes in both patches are identical to upstream.
The complete fix is already present in 6.12.y, 6.18.y and 7.2.y.
Build-tested only as part of a cumulative 6.6.y series: x86_64 objects (allmodconfig, CONFIG_WERROR=y); no runtime testing.
An LLM assisted with preparing these backports.
Thanks,
Artem Dinaburg
PATCH 1/2 llist: add interface to check if a node is on a list.
From: NeilBrown <[email protected]>
[ Upstream commit d6b3358a2813bb14791259a2227d9af1e7019ca0 ]
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.
---
Hi,
Please consider this backport of the prerequisite for CVE-2025-38264 to 6.6.y.
The code changes are identical to upstream.
The complete fix is already present in 6.12.y, 6.18.y and 7.2.y.
Build-tested only as part of a cumulative 6.6.y series: x86_64 objects (allmodconfig, CONFIG_WERROR=y); no runtime testing.
Thanks,
Artem Dinaburg
include/linux/llist.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
include/linux/llist.h +42 -0
@@ -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 */
PATCH 2/2 nvme-tcp: sanitize request list handling
In reply to Artem DinaburgFrom: Hannes Reinecke <[email protected]>
[ Upstream commit 0bf04c874fcb1ae46a863034296e4b33d8fbd66c ]
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.
---
Hi,
Please consider this backport of the fix for CVE-2025-38264 to 6.6.y.
The code changes are identical to upstream.
The complete fix is already present in 6.12.y, 6.18.y and 7.2.y.
Build-tested only as part of a cumulative 6.6.y series: x86_64 objects (allmodconfig, CONFIG_WERROR=y); no runtime testing.
Thanks,
Artem Dinaburg
drivers/nvme/host/tcp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/nvme/host/tcp.c +14 -1
@@ -385,7 +385,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; }
@@ -493,6 +494,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 ; }
@@ -739,6 +742,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;
@@ -2374,6 +2385,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); }
Quoted 1 line
Please consider this backport series for CVE-2025-38264 to 6.6.y.
Queued the series for 6.6, thanks.
Signature · 2 lines
Thanks, Sasha