From patchwork Fri Feb 3 14:49:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 139403 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 268DE104796 for ; Sat, 4 Feb 2012 02:55:07 +1100 (EST) Received: from localhost ([::1]:39800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtKSx-0000gs-R5 for incoming@patchwork.ozlabs.org; Fri, 03 Feb 2012 09:50:19 -0500 Received: from eggs.gnu.org ([140.186.70.92]:46237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtKSN-0007uY-Mi for qemu-devel@nongnu.org; Fri, 03 Feb 2012 09:49:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RtKSE-0001UP-WA for qemu-devel@nongnu.org; Fri, 03 Feb 2012 09:49:43 -0500 Received: from afflict.kos.to ([92.243.29.197]:49806) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtKSE-0001Th-PW for qemu-devel@nongnu.org; Fri, 03 Feb 2012 09:49:34 -0500 Received: by afflict.kos.to (Postfix, from userid 1000) id 78A4B26537; Fri, 3 Feb 2012 14:49:32 +0000 (UTC) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 3 Feb 2012 16:49:25 +0200 Message-Id: X-Mailer: git-send-email 1.7.1 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 92.243.29.197 Cc: Peter Maydell Subject: [Qemu-devel] [PATCH 12/19] linux-user: Allow NULL value pointer in setxattr and getxattr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Maydell It's valid to pass a NULL value pointer to setxattr, so don't fail this case EFAULT. Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 24 ++++++++++++++++++------ 1 files changed, 18 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 06b19e0..0a78a18 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7809,11 +7809,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; case TARGET_NR_setxattr: { - void *p, *n, *v; + void *p, *n, *v = 0; + if (arg3) { + v = lock_user(VERIFY_READ, arg3, arg4, 1); + if (!v) { + ret = -TARGET_EFAULT; + break; + } + } p = lock_user_string(arg1); n = lock_user_string(arg2); - v = lock_user(VERIFY_READ, arg3, arg4, 1); - if (p && n && v) { + if (p && n) { ret = get_errno(setxattr(p, n, v, arg4, arg5)); } else { ret = -TARGET_EFAULT; @@ -7825,11 +7831,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; case TARGET_NR_getxattr: { - void *p, *n, *v; + void *p, *n, *v = 0; + if (arg3) { + v = lock_user(VERIFY_WRITE, arg3, arg4, 0); + if (!v) { + ret = -TARGET_EFAULT; + break; + } + } p = lock_user_string(arg1); n = lock_user_string(arg2); - v = lock_user(VERIFY_WRITE, arg3, arg4, 0); - if (p && n && v) { + if (p && n) { ret = get_errno(getxattr(p, n, v, arg4)); } else { ret = -TARGET_EFAULT;