From 34bf6df75d17625b0042df7e9e09b7cb1d88790d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 30 Nov 2016 21:12:01 -0800 Subject: [PATCH] iscsi-scst: Restore msg->msg_iov check --- iscsi-scst/kernel/nthread.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index ed041cc04..4c60d4b3c 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -697,6 +697,10 @@ static int do_recv(struct iscsi_conn *conn) mm_segment_t oldfs; struct msghdr *msg; int read_size; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) + struct iovec *first_iov; + int first_len; +#endif EXTRACHECKS_BUG_ON(conn->read_cmnd == NULL); @@ -717,6 +721,8 @@ restart: read_size = msg->msg_iter.count; #else read_size = conn->read_size; + first_iov = msg->msg_iov; + first_len = first_iov->iov_len; #endif oldfs = get_fs(); @@ -746,7 +752,7 @@ restart: sBUG_ON(msg->msg_iter.count + res != read_size); res = msg->msg_iter.count; #else - /* To do: restore msg->msg_iov check. */ + sBUG_ON((res >= first_len) && (first_iov->iov_len != 0)); conn->read_size -= res; res = conn->read_size; #endif