From patchwork Wed Dec 14 15:37:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 5701 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 5AF9A23E0E for ; Wed, 14 Dec 2011 15:37:24 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id 47DB7A18050 for ; Wed, 14 Dec 2011 15:37:24 +0000 (UTC) Received: by eaak10 with SMTP id k10so750954eaa.11 for ; Wed, 14 Dec 2011 07:37:24 -0800 (PST) Received: by 10.205.129.137 with SMTP id hi9mr1245258bkc.90.1323877044042; Wed, 14 Dec 2011 07:37:24 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.129.2 with SMTP id hg2cs12023bkc; Wed, 14 Dec 2011 07:37:23 -0800 (PST) Received: by 10.205.125.10 with SMTP id gq10mr1202644bkc.11.1323877042642; Wed, 14 Dec 2011 07:37:22 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id fk5si1156152bkc.86.2011.12.14.07.37.22 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Dec 2011 07:37:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1RaqtT-0005BI-Q0; Wed, 14 Dec 2011 15:37:19 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Riku Voipio Subject: [PATCH 1/3] linux-user: Allow NULL value pointer in setxattr and getxattr Date: Wed, 14 Dec 2011 15:37:17 +0000 Message-Id: <1323877039-19891-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1323877039-19891-1-git-send-email-peter.maydell@linaro.org> References: <1323877039-19891-1-git-send-email-peter.maydell@linaro.org> It's valid to pass a NULL value pointer to setxattr, so don't fail this case EFAULT. Signed-off-by: Peter Maydell --- 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 f227097..ca4503d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7655,11 +7655,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; @@ -7671,11 +7677,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;