From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KulhG-00076h-Bk for qemu-devel@nongnu.org; Tue, 28 Oct 2008 06:21:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KulhF-00076G-Aj for qemu-devel@nongnu.org; Tue, 28 Oct 2008 06:21:09 -0400 Received: from [199.232.76.173] (port=42180 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KulhE-000761-MI for qemu-devel@nongnu.org; Tue, 28 Oct 2008 06:21:08 -0400 Received: from savannah.gnu.org ([199.232.41.3]:53929 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KulhE-00086v-Ml for qemu-devel@nongnu.org; Tue, 28 Oct 2008 06:21:08 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KulhD-0000W2-1m for qemu-devel@nongnu.org; Tue, 28 Oct 2008 10:21:07 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KulhB-0000Vi-HL for qemu-devel@nongnu.org; Tue, 28 Oct 2008 10:21:06 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Tue, 28 Oct 2008 10:21:05 +0000 Subject: [Qemu-devel] [5562] Fix iovec for the case with invalid elements (Lauro Ramos Venancio). Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5562 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5562 Author: balrog Date: 2008-10-28 10:21:03 +0000 (Tue, 28 Oct 2008) Log Message: ----------- Fix iovec for the case with invalid elements (Lauro Ramos Venancio). We must call the writev even if an iovec element is invalid. For example, if the second element is invalid, the linux process the first one. Modified Paths: -------------- trunk/linux-user/syscall.c Modified: trunk/linux-user/syscall.c =================================================================== --- trunk/linux-user/syscall.c 2008-10-28 10:18:28 UTC (rev 5561) +++ trunk/linux-user/syscall.c 2008-10-28 10:21:03 UTC (rev 5562) @@ -1064,7 +1064,7 @@ { struct target_iovec *target_vec; abi_ulong base; - int i, j; + int i; target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1); if (!target_vec) @@ -1074,8 +1074,8 @@ vec[i].iov_len = tswapl(target_vec[i].iov_len); if (vec[i].iov_len != 0) { vec[i].iov_base = lock_user(type, base, vec[i].iov_len, copy); - if (!vec[i].iov_base && vec[i].iov_len) - goto fail; + /* Don't check lock_user return value. We must call writev even + if a element has invalid base address. */ } else { /* zero length pointer is ignored */ vec[i].iov_base = NULL; @@ -1083,14 +1083,6 @@ } unlock_user (target_vec, target_addr, 0); return 0; - fail: - /* failure - unwind locks */ - for (j = 0; j < i; j++) { - base = tswapl(target_vec[j].iov_base); - unlock_user(vec[j].iov_base, base, 0); - } - unlock_user (target_vec, target_addr, 0); - return -TARGET_EFAULT; } static abi_long unlock_iovec(struct iovec *vec, abi_ulong target_addr, @@ -1104,8 +1096,10 @@ if (!target_vec) return -TARGET_EFAULT; for(i = 0;i < count; i++) { - base = tswapl(target_vec[i].iov_base); - unlock_user(vec[i].iov_base, base, copy ? vec[i].iov_len : 0); + if (target_vec[i].iov_base) { + base = tswapl(target_vec[i].iov_base); + unlock_user(vec[i].iov_base, base, copy ? vec[i].iov_len : 0); + } } unlock_user (target_vec, target_addr, 0);