From patchwork Fri Aug 15 11:01:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35431 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B61EF203C5 for ; Fri, 15 Aug 2014 11:05:13 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id h18sf4039137igc.1 for ; Fri, 15 Aug 2014 04:05:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=4eSBTViasNR+OwvbwfaKzsXr3kVkrhMabgfgqmqJH1o=; b=Hii4STvq0IqF8KTHjcwhi1yirpuXGSanobu+ituj1eMdL5q6trTUrhBTzwAp8xcPCV iTqxXjL7csS41sYWGYt4NgdEL/l50Mgwq2hAAodHkOJtByYIIotI3YRXZ1faZeDm3k4o dFxE02YdzNF7T2eLnKVvfwjqR/rhZJRh9P8qu4SdfARw6DVvp9MoXVfxzXKxtg3EWRSx skh3fA59yLcq0lh3LjYRIzWMvx0X/v5jhgFVTKLl1+nkD/xi2d7TpAmAApB+dqeSGDMu jkncLXsu7Bc4BptedDbxarAZeUmdYP5MiSNh5052Z/2n+J5rA5kj6Z6dXLjbGJ/OWnso 4u0Q== X-Gm-Message-State: ALoCoQlTBQ1+uMfP2EsweIlSjQMa+MQv6d+WMQdYTfoYwjOaM5rt1giowEH8ygKnKRTZCERqu3Wz X-Received: by 10.182.123.163 with SMTP id mb3mr8652972obb.32.1408100713258; Fri, 15 Aug 2014 04:05:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.86.9 with SMTP id o9ls946400qgd.47.gmail; Fri, 15 Aug 2014 04:05:13 -0700 (PDT) X-Received: by 10.229.59.67 with SMTP id k3mr26593834qch.26.1408100713189; Fri, 15 Aug 2014 04:05:13 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id q93si11322775qgd.109.2014.08.15.04.05.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:05:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id hy10so2778760vcb.18 for ; Fri, 15 Aug 2014 04:05:13 -0700 (PDT) X-Received: by 10.52.83.227 with SMTP id t3mr13047431vdy.20.1408100712990; Fri, 15 Aug 2014 04:05:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp104118vcb; Fri, 15 Aug 2014 04:05:12 -0700 (PDT) X-Received: by 10.140.93.161 with SMTP id d30mr24876293qge.53.1408100712225; Fri, 15 Aug 2014 04:05:12 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r9si11330387qcj.46.2014.08.15.04.05.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:05:12 -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; Received: from localhost ([::1]:58554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFJn-0001Jb-PU for patch@linaro.org; Fri, 15 Aug 2014 07:05:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGb-0004x0-Uw for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:02:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIFGU-00072c-VT for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:53 -0400 Received: from afflict.kos.to ([92.243.29.197]:57584) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGU-00071E-P8 for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:46 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 21B9226684; Fri, 15 Aug 2014 13:01:45 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 15 Aug 2014 14:01:34 +0300 Message-Id: <989c10af553dbdb9ec7054c75e4cc5bcde015d3d.1408100160.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Peter Maydell , Tom Musta Subject: [Qemu-devel] [PULL 16/24] linux-user: Detect Negative Message Sizes in msgsnd System Call 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Tom Musta The msgsnd system call takes an argument that describes the message size (msgsz) and is of type size_t. The system call should set errno to EINVAL in the event that a negative message size is passed. Signed-off-by: Tom Musta Reviewed-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c9a9d3d..d223cff 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2879,12 +2879,16 @@ struct target_msgbuf { }; static inline abi_long do_msgsnd(int msqid, abi_long msgp, - unsigned int msgsz, int msgflg) + ssize_t msgsz, int msgflg) { struct target_msgbuf *target_mb; struct msgbuf *host_mb; abi_long ret = 0; + if (msgsz < 0) { + return -TARGET_EINVAL; + } + if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0)) return -TARGET_EFAULT; host_mb = malloc(msgsz+sizeof(long));