All projects

Upstream commits

Linux® Kernel

torvalds/linux

NULL pointer dereference and use-after-free fixes in the NVMe TCP and RDMA host drivers, and request PDU sizing with header digest.

View on GitHub

6 commits

  1. liveupdate: check for duplicate session before growing block set
    luo_session_insert() grows the outgoing block set before checking for a duplicate session name. On -EEXIST the new block stays in the set. If the session count is an exact multiple of the per-block capacity (51 with 4K pages), that block stays empty. It is serialized with count 0, which kho_block_set_restore() rejects in the next kernel: luo: Block contains invalid entry count: 0 Kernel panic - not syncing: The incoming tree failed to initialize properly [-EINVAL], disabling live update Check for the duplicate before growing the block set, as luo_preserve_file() does with the token.
  2. nvme-tcp: fix use-after-free in nvme_tcp_free_ctrl()
    nvme_tcp_free_ctrl() reads ctrl->ctrl.opts to know how many queue mutexes to destroy. When creating the controller fails, nvmf_create_ctrl() frees opts as soon as nvme_tcp_create_ctrl() returns, but a concurrent open of the character device can hold the last reference to the controller. With CONFIG_DEBUG_KOBJECT_RELEASE, which delays the release, every failed connect reads freed memory: BUG: KASAN: slab-use-after-free in nvme_tcp_free_ctrl+0x38b/0x430 Read of size 4 at addr ffff888005b93740 by task kworker/2:1/51 Keep the size of the queue array in the controller and use it instead.
  3. nvme-rdma: fix NULL queue->ctrl dereference on reconnect
    Since commit 2a8513091d2f ("nvme-rdma: parallelize I/O queue allocation and startup"), a reconnect that gets more I/O queues than before grows the tag set before the new queues are set up. queue->ctrl is only set by nvme_rdma_setup_io_queues(), so I/O submitted in between reaches nvme_rdma_queue_rq() on a queue that was never allocated and dereferences a NULL queue->ctrl: BUG: kernel NULL pointer dereference, address: 000000000000034c RIP: 0010:nvme_rdma_queue_rq+0x52/0xb90 Set queue->ctrl for every queue when allocating the controller. Such requests are then requeued like on any other queue that is not live.
  4. nvme-tcp: fix NULL queue->ctrl dereference on reconnect
    Since commit 61b0ed3be81b ("nvme-tcp: parallelize I/O queue allocation and startup"), a reconnect that gets more I/O queues than before grows the tag set before the new queues are allocated. queue->ctrl is only set by nvme_tcp_alloc_queue(), so I/O submitted in between reaches nvme_tcp_queue_rq() on a queue that was never allocated and dereferences a NULL queue->ctrl: BUG: kernel NULL pointer dereference, address: 00000000000002ac RIP: 0010:nvme_tcp_queue_rq+0x33/0x3b0 Add nvme_tcp_init_queue() for the queue fields that do not depend on the connection and call it for every queue when allocating the controller. Such requests are then requeued like on any other queue that is not live. send_mutex and io_work move there as well, and nvme_tcp_exit_queue() destroys the helper's mutexes when the controller is freed. [kbusch: dropped the comment above nvme_tcp_init_queue()]
  5. nvme-tcp: fix request PDU size when header digest is enabled
    Since commit 61b0ed3be81b ("nvme-tcp: parallelize I/O queue allocation and startup") the I/O tag set is allocated before the I/O queues. nvme_tcp_init_request() sizes the PDU with nvme_tcp_hdgst_len(queue), but queue->hdr_digest is only set later by nvme_tcp_alloc_queue(), so every I/O PDU is allocated without room for the header digest. With hdr_digest enabled, the digest is then written 4 bytes past the PDU, over the header of the next PDU in the page_frag cache, and the target drops the connection on the first I/O: nvmet_tcp: unexpected pdu type 159 nvmet: ctrl 1 fatal error occurred! Queues that a later reconnect adds for the first time have the same problem. Set queue->hdr_digest when allocating the controller, together with pf_cache_lock, so it is valid before any request is initialized.
  6. nvme-rdma: fix NULL metadata_sgl dereference with T10-PI
    Since commit 2a8513091d2f ("nvme-rdma: parallelize I/O queue allocation and startup") the I/O tag set is allocated before the I/O queues. nvme_rdma_init_request() only sets req->metadata_sgl if queue->pi_support is set, but pi_support is only set later by nvme_rdma_alloc_queue(), so every I/O request is left with a NULL metadata_sgl. With an RDMA device that supports integrity and a namespace formatted with protection information, nvme_rdma_dma_map_req() then dereferences the NULL pointer on the first integrity I/O, already during the namespace scan when there is more than one I/O queue. Queues that a later reconnect adds for the first time have the same problem. Check queue_idx and the controller's max_integrity_segments instead, which is what nvme_rdma_alloc_queue() derives pi_support from.

Updated daily, last on 2026-11-16. By Christian Aurich Zanettini Martins · All projects