From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:60371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBiUA-00026t-CK for qemu-devel@nongnu.org; Mon, 18 Apr 2011 03:03:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QBiU9-0000Hf-0Q for qemu-devel@nongnu.org; Mon, 18 Apr 2011 03:03:02 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:17136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBiU8-0000H9-GU for qemu-devel@nongnu.org; Mon, 18 Apr 2011 03:03:00 -0400 Received: from epmmp2 (mailout3.samsung.com [203.254.224.33]) by mailout3.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTP id <0LJU00MS268Q0400@mailout3.samsung.com> for qemu-devel@nongnu.org; Mon, 18 Apr 2011 16:02:50 +0900 (KST) Received: from TNRNDGASPAPP1.tn.corp.samsungelectronics.net ([165.213.149.150]) by mmp2.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LJU00C4068QCP@mmp2.samsung.com> for qemu-devel@nongnu.org; Mon, 18 Apr 2011 16:02:51 +0900 (KST) Date: Mon, 18 Apr 2011 16:03:59 +0900 From: Mike McCormack Message-id: <4DABE25F.8000203@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7BIT Subject: [Qemu-devel] [PATCH] Don't zero out buffer in sched_getaffinity List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, riku.voipio@nokia.com, vapier@gentoo.org The kernel doesn't fill the buffer provided to sched_getaffinity with zero bytes, so neither should QEMU. Depends on sched_getaffinity buffer overrun fix, but submitted separately to make rollback easier. --- linux-user/syscall.c | 13 +------------ 1 files changed, 1 insertions(+), 12 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 19209a2..e2a5fd9 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6382,20 +6382,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(sys_sched_getaffinity(arg1, mask_size, mask)); if (!is_error(ret)) { - if (arg2 > ret) { - /* Zero out any extra space kernel didn't fill */ - unsigned long zero = arg2 - ret; - p = alloca(zero); - memset(p, 0, zero); - if (copy_to_user(arg3 + ret, p, zero)) { - goto efault; - } - arg2 = ret; - } - if (copy_to_user(arg3, mask, arg2)) { + if (copy_to_user(arg3, mask, ret)) { goto efault; } - ret = arg2; } } break; -- 1.7.0.4