Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

target: Fix parameter list length checking in MODE SELECT

An empty parameter list (length == 0) is not an error, so succeed MODE
SELECT in this case. If the parameter list length is too small,
return the correct sense code of PARAMETER LIST LENGTH ERROR.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

authored by

Roland Dreier and committed by
Nicholas Bellinger
71f41fe1 bb992e72

+13
+13
drivers/target/target_core_spc.c
··· 1000 1000 int ret = 0; 1001 1001 int i; 1002 1002 1003 + if (!cmd->data_length) { 1004 + target_complete_cmd(cmd, GOOD); 1005 + return 0; 1006 + } 1007 + 1008 + if (cmd->data_length < off + 2) 1009 + return TCM_PARAMETER_LIST_LENGTH_ERROR; 1010 + 1003 1011 buf = transport_kmap_data_sg(cmd); 1004 1012 if (!buf) 1005 1013 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; ··· 1032 1024 goto out; 1033 1025 1034 1026 check_contents: 1027 + if (cmd->data_length < off + length) { 1028 + ret = TCM_PARAMETER_LIST_LENGTH_ERROR; 1029 + goto out; 1030 + } 1031 + 1035 1032 if (memcmp(buf + off, tbuf, length)) 1036 1033 ret = TCM_INVALID_PARAMETER_LIST; 1037 1034