diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2013-11-13 02:48:11 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-12-16 13:57:51 -0500 |
commit | 3c60cfd73966797746530768d66597d025a69804 (patch) | |
tree | 106cff66b2b58a8f4bf5c819942155fbca2029c4 | |
parent | 88397c279d6d113ef67be254bc145d198e733844 (diff) |
[SCSI] qla4xxx: overflow in qla4xxx_set_chap_entry()
We should cap the size of memcpy() because it comes from the network
and can't be trusted.
Fixes: 26ffd7b45fe9 ('[SCSI] qla4xxx: Add support to set CHAP entries')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_os.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index b04afaefde84..4706b8c0ec64 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c | |||
@@ -861,6 +861,7 @@ static int qla4xxx_set_chap_entry(struct Scsi_Host *shost, void *data, int len) | |||
861 | int type; | 861 | int type; |
862 | int rem = len; | 862 | int rem = len; |
863 | int rc = 0; | 863 | int rc = 0; |
864 | int size; | ||
864 | 865 | ||
865 | memset(&chap_rec, 0, sizeof(chap_rec)); | 866 | memset(&chap_rec, 0, sizeof(chap_rec)); |
866 | 867 | ||
@@ -875,12 +876,14 @@ static int qla4xxx_set_chap_entry(struct Scsi_Host *shost, void *data, int len) | |||
875 | chap_rec.chap_type = param_info->value[0]; | 876 | chap_rec.chap_type = param_info->value[0]; |
876 | break; | 877 | break; |
877 | case ISCSI_CHAP_PARAM_USERNAME: | 878 | case ISCSI_CHAP_PARAM_USERNAME: |
878 | memcpy(chap_rec.username, param_info->value, | 879 | size = min_t(size_t, sizeof(chap_rec.username), |
879 | param_info->len); | 880 | param_info->len); |
881 | memcpy(chap_rec.username, param_info->value, size); | ||
880 | break; | 882 | break; |
881 | case ISCSI_CHAP_PARAM_PASSWORD: | 883 | case ISCSI_CHAP_PARAM_PASSWORD: |
882 | memcpy(chap_rec.password, param_info->value, | 884 | size = min_t(size_t, sizeof(chap_rec.password), |
883 | param_info->len); | 885 | param_info->len); |
886 | memcpy(chap_rec.password, param_info->value, size); | ||
884 | break; | 887 | break; |
885 | case ISCSI_CHAP_PARAM_PASSWORD_LEN: | 888 | case ISCSI_CHAP_PARAM_PASSWORD_LEN: |
886 | chap_rec.password_length = param_info->value[0]; | 889 | chap_rec.password_length = param_info->value[0]; |