From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932187AbaHHVtP (ORCPT ); Fri, 8 Aug 2014 17:49:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60832 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758474AbaHHVqI (ORCPT ); Fri, 8 Aug 2014 17:46:08 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sasha Levin , "David S. Miller" Subject: [PATCH 3.16 07/17] iovec: make sure the caller actually wants anything in memcpy_fromiovecend Date: Fri, 8 Aug 2014 14:35:29 -0700 Message-Id: <20140808213457.813218974@linuxfoundation.org> X-Mailer: git-send-email 2.0.4 In-Reply-To: <20140808213457.511493898@linuxfoundation.org> References: <20140808213457.511493898@linuxfoundation.org> User-Agent: quilt/0.63-1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sasha Levin [ Upstream commit 06ebb06d49486676272a3c030bfeef4bd969a8e6 ] Check for cases when the caller requests 0 bytes instead of running off and dereferencing potentially invalid iovecs. Signed-off-by: Sasha Levin Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- lib/iovec.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/lib/iovec.c +++ b/lib/iovec.c @@ -85,6 +85,10 @@ EXPORT_SYMBOL(memcpy_toiovecend); int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov, int offset, int len) { + /* No data? Done! */ + if (len == 0) + return 0; + /* Skip over the finished iovecs */ while (offset >= iov->iov_len) { offset -= iov->iov_len;