Skip to content

Commit e7077e6

Browse files
committed
nvmet-tcp: Do not WARN on remotely-controlled oversized SGL allocations
commit 737a3b5 upstream. When fuzzing the nvme target code, I tripped a kernel warning in nvmet_tcp_map_data() because the length passed into the allocator is controlled by the remote initiator. A remote initiator that sends a command with an SGL claiming a huge number, can create a scatterlist and iovec allocation of over 1 million entries, which causes the backing kmalloc call to exceed MAX_PAGE_ORDER and then the page allocator will trip on a WARN_ON_ONCE_GFP() message: WARNING: mm/page_alloc.c:5280 __alloc_frozen_pages_noprof Workqueue: nvmet_tcp_wq nvmet_tcp_io_work ... sgl_alloc_order nvmet_tcp_map_data nvmet_tcp_try_recv_pdu As it's never good to trip a kernel warning remotely due to many systems having panic-on-warn enabled, let's silence it by just add GFP_NOWARN to the allocation flags. Assisted-by: gkh_clanker_2000 Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1a8f007 commit e7077e6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/nvme/target/tcp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,15 @@ static int nvmet_tcp_map_data(struct nvmet_tcp_cmd *cmd)
401401
}
402402
cmd->req.transfer_len += len;
403403

404-
cmd->req.sg = sgl_alloc(len, GFP_KERNEL, &cmd->req.sg_cnt);
404+
cmd->req.sg = sgl_alloc(len, GFP_KERNEL | __GFP_NOWARN,
405+
&cmd->req.sg_cnt);
405406
if (!cmd->req.sg)
406407
return NVME_SC_INTERNAL;
407408
cmd->cur_sg = cmd->req.sg;
408409

409410
if (nvmet_tcp_has_data_in(cmd)) {
410411
cmd->iov = kmalloc_array(cmd->req.sg_cnt,
411-
sizeof(*cmd->iov), GFP_KERNEL);
412+
sizeof(*cmd->iov), GFP_KERNEL | __GFP_NOWARN);
412413
if (!cmd->iov)
413414
goto err;
414415
}

0 commit comments

Comments
 (0)