From patchwork Thu Sep 22 12:13:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 76760 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp4245qgf; Thu, 22 Sep 2016 05:31:19 -0700 (PDT) X-Received: by 10.55.79.139 with SMTP id d133mr1734738qkb.110.1474547479068; Thu, 22 Sep 2016 05:31:19 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c186si964939qkf.208.2016.09.22.05.31.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 22 Sep 2016 05:31:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn39q-0005pU-Hy for patch@linaro.org; Thu, 22 Sep 2016 08:31:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2uE-0008LC-2o for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn2u9-0006TL-2r for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:09 -0400 Received: from mail-lf0-f51.google.com ([209.85.215.51]:34221) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2u8-0006T9-RW for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:05 -0400 Received: by mail-lf0-f51.google.com with SMTP id y6so65851638lff.1 for ; Thu, 22 Sep 2016 05:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U7ljAFFqMZvNFQgXZR4l7VhblBX79gbDjkLLF6XJgSo=; b=WMKM2J/rht0jmOZCUgOrFPblimAb83SOH3hvK7Ty+CCGkyebMWCWIaS220VIZlvDa2 O0zO5Y0eFXQbuZs32aNz0icVzFGdGTTYQuaFeCGDQJ4xy/KGktmMtBFM4yZYJorcXCke gqTMvmaQhWKcQS9sXrq4drQsB2+CJL2aYeqFo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U7ljAFFqMZvNFQgXZR4l7VhblBX79gbDjkLLF6XJgSo=; b=Ig/8f7VVLIHz5rZN9o6OayUfqVmX3YiBso5fhqzCRIKValXYH6qByM2U/kVbM+kQri tsCRcCHvrzc7ESvnaH1L8iKCpAM7CwTh2kbzyidtpDH2iBOo6D2sjMYh7ZQ/2gOm0Qto tlZQJl4yglcDk6s1R6Lht1mmFMgiUSpsaeCZyerUotBgbIOVtAEXJVt9xMj1auyu66rg MJfsl3Rhd7RSFBEd9bUbi071LoIM9d4gaCaGQ3A04oJTODND11TgRJY2lE+iP9J85hrP JSFR6yJwWpqczW93f5XcPOVljDbaEnV8l3c7Y2KXKHDTJeBAJpDpP4YwjY7keITS7OIM ShCQ== X-Gm-Message-State: AE9vXwPUIC9uZhu6DFCsUPa52t+4Htlj35Jvqa4al9RkDlKzvf1UWW/QExLE0zYjJC9Wx5An X-Received: by 10.25.152.83 with SMTP id a80mr742328lfe.144.1474546444048; Thu, 22 Sep 2016 05:14:04 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id u14sm294378lja.11.2016.09.22.05.14.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Sep 2016 05:14:03 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 22 Sep 2016 15:13:30 +0300 Message-Id: <3211215e741f6e4824ddfc4919428e8d1b82a3c2.1474546244.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.215.51 Subject: [Qemu-devel] [PULL 10/26] linux-user: Check lock_user() return value for NULL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell lock_user() can return NULL, which typically means the syscall should fail with EFAULT. Add checks in various places where Coverity spotted that we were missing them. Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.1.4 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7a50a57..efcc17a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5008,6 +5008,11 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd, host_data = (char*)host_dm + host_dm->data_start; argptr = lock_user(VERIFY_READ, guest_data, guest_data_size, 1); + if (!argptr) { + ret = -TARGET_EFAULT; + goto out; + } + switch (ie->host_cmd) { case DM_REMOVE_ALL: case DM_LIST_DEVICES: @@ -11271,6 +11276,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_mq_unlink: p = lock_user_string(arg1 - 1); + if (!p) { + ret = -TARGET_EFAULT; + break; + } ret = get_errno(mq_unlink(p)); unlock_user (p, arg1, 0); break;