From patchwork Fri Aug 22 13:24:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35817 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9E03F20540 for ; Fri, 22 Aug 2014 13:39:02 +0000 (UTC) Received: by mail-oi0-f70.google.com with SMTP id u20sf54664350oif.9 for ; Fri, 22 Aug 2014 06:39:02 -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=XCkb7Tbd3DJPbYiPuUdzpU+YeN/mapjQmk90pcwgwJc=; b=MbPutjYaMJOc+P4YWV6+/IjDXNDZrdHevxVrf+mM2uk57tP0mOorTH3EVeUALaetLN hdOKiyZApIkRTWU3P8w2k9yhaUoIEMzxDCKm6Qc5LmiBOMge7bEYRYC14kFXLJ0K3rEb 9ojEjcM9/ci+trHT+bM2uaXFUBtbSm0pSBXCECYyn6OXoDiESnPnss9v9YaqlWkviE5p swKIYA4tuGTvQmkKCo+SzKf84aSl+VOOMlVXzRDTNfw+xw2dzpe52UcQ+lhqQ15dYpmU VOG/4oWRDOYEWMKbAmmYyf1A7XwQ9/cYET/cqED5DJAVNuJ6s3q2+NpY/bTRM/myagAT ghdg== X-Gm-Message-State: ALoCoQlHQxVIGBShVh8uzwnkJnpwxtLeOYJfRgeSR54q2gXv+sS47xDSq+VDLldtazS+faAs0RLs X-Received: by 10.182.107.135 with SMTP id hc7mr3248397obb.48.1408714741838; Fri, 22 Aug 2014 06:39:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.97.100 with SMTP id l91ls1101476qge.69.gmail; Fri, 22 Aug 2014 06:39:01 -0700 (PDT) X-Received: by 10.221.62.7 with SMTP id wy7mr89274vcb.66.1408714741670; Fri, 22 Aug 2014 06:39:01 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id cy9si13565785vdb.102.2014.08.22.06.39.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:39:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ij19so12387831vcb.11 for ; Fri, 22 Aug 2014 06:39:01 -0700 (PDT) X-Received: by 10.221.68.135 with SMTP id xy7mr89277vcb.65.1408714741560; Fri, 22 Aug 2014 06:39:01 -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.45.67 with SMTP id uj3csp17668vcb; Fri, 22 Aug 2014 06:39:01 -0700 (PDT) X-Received: by 10.140.48.5 with SMTP id n5mr7485454qga.102.1408714740840; Fri, 22 Aug 2014 06:39:00 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m8si42272974qaa.73.2014.08.22.06.39.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:39:00 -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]:37202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKp3U-0001ZJ-GG for patch@linaro.org; Fri, 22 Aug 2014 09:39:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKops-0006c4-5v for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:25:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKoph-0002Dc-I3 for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:56 -0400 Received: from [2001:4b98:dc0:45:216:3eff:fe3d:166f] (port=54484 helo=afflict.kos.to) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKoph-0002Cf-B5 for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:45 -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 1A7BF2658A; Fri, 22 Aug 2014 15:24:43 +0200 (CEST) From: riku.voipio@linaro.org To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 22 Aug 2014 16:24:32 +0300 Message-Id: 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: 2001:4b98:dc0:45:216:3eff:fe3d:166f Cc: Tom Musta Subject: [Qemu-devel] [PULL v3 14/22] 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.180 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 e754dbb..2549249 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));