target: Reject SCSI data overflow for fabrics using transport_generic_map_mem_to_cmd
authorNicholas Bellinger <nab@linux-iscsi.org>
Wed, 16 Nov 2011 06:13:24 +0000 (22:13 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 21 Dec 2011 20:58:28 +0000 (12:58 -0800)
commit1c9c1ada7ee0b4b42e451d35153dff3735b28cac
treed60a25f8b412c70bdfa9fb475a8b4104f67e9816
parentf55f75a191f661f652920f788501e6546a60c3f5
target: Reject SCSI data overflow for fabrics using transport_generic_map_mem_to_cmd

commit fef58a6096770ed6ab49103a430cc755254a74d9 upstream.

This patch changes transport_generic_map_mem_to_cmd() to reject SCSI data
overflow and to send exception status with CHECK_CONDITION + TCM_INVALID_CDB_FIELD
for fabrics that are passing a pre-populated struct scatterlist (eg: tcm_loop
and iscsi-target) being mapped into se_cmd->t_data_sg and se_cmd->t_data_nents.

This addresses an OOPs where transport_allocate_data_tasks() would walk
the incorrect post OVERFLOW cmd->data_length value beyond the end of
the passed scatterlist.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Andy Grover <agrover@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/target/target_core_transport.c