From patchwork Thu May 31 22:49:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137445 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp207900lji; Thu, 31 May 2018 15:49:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ/ZdCh4FmVdTdRiQlyVjsJNCeFxmpPN2K/8NuZa6wNRU38PM+PO6ptEBFnVq5Z8d8Qzm2O X-Received: by 2002:a37:7742:: with SMTP id s63-v6mr7796012qkc.97.1527806990465; Thu, 31 May 2018 15:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527806990; cv=none; d=google.com; s=arc-20160816; b=tEMChNh+UbYKZ0E8smkeZb1siI8reIdAws5yutfSXrGJOaJtDTEN9mR0wkFmDd5hPt ZFzST/dlb82kJ7LbZNI0ld/oOuHN4rBRDtyXu3TiWKJecOA7YOlEZPB+TONEbvNQ+sj1 NardmIYNHlJKgUSY4ijVF+4SKneOjkJ4RCgHruBi2h9MefMbXGI1Ncts07WtQsuH+LKz XUnB3+3EGpkeGagQnoRYVpfJYq5ohL3g5O4GYOUC4ZxRL1rTDNFUlbmh44t7HcLxSuIL 966uDkeIZpOQ+lv6tTHIFZKj35lyPInKeG47iw0jPMc7T6c6p8q8/QxXsTWz68bY0XMg u1yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Q1iNbE7b2UYUJKQIqBMPbPcIDxffIQfiNgT2DyF9Ne0=; b=RrMhZSMBSCDf0e484ca9cx1AL8FE0JWQh92jXQsOakG3BtTS4Hlhymg7xPs4qEq3fC fMw3Qx0j8VJzXMooRp3r8LRr7Wq6AKgmmJco0SaPie8ARAMmCjaC379y17jy9kBfEtl6 0/5EcTjSo2Dtn4JE1lsQVh1Bh6EN6c1WSYUTUi8SSv0JbwgMA71cis+B7N7YIeCGp9wK bTghvob6yTNyxFnghNMxoXLJsjLd3gi3bNk/3ubUZq/7uXjgjBxT0J780Xu8S+fcOvS6 4OMXcWSwLTlZdPrAxgl1AeQkKYSdnr5kCdBGeY7nH2xB8JqyMKiZeHem5D7ORqplNa27 D9/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ILKiSk7K; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d64-v6si5964272qkf.220.2018.05.31.15.49.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 31 May 2018 15:49:50 -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 header.s=google header.b=ILKiSk7K; 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 sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOWOD-0005F5-TN for patch@linaro.org; Thu, 31 May 2018 18:49:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOWNn-0005Aj-Ev for qemu-devel@nongnu.org; Thu, 31 May 2018 18:49:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOWNm-0000pe-MG for qemu-devel@nongnu.org; Thu, 31 May 2018 18:49:23 -0400 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]:36718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOWNm-0000p5-Gv for qemu-devel@nongnu.org; Thu, 31 May 2018 18:49:22 -0400 Received: by mail-pf0-x231.google.com with SMTP id w129-v6so11499025pfd.3 for ; Thu, 31 May 2018 15:49:22 -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=Q1iNbE7b2UYUJKQIqBMPbPcIDxffIQfiNgT2DyF9Ne0=; b=ILKiSk7K5205eB5+ztRNKyiGmk3yhvOqgSnhlUOQQUzcEqe9PzD1Mx2ssOdYfbyYJT Zfkr8O3B3QChado6oJ7aYVsD7MKY2pPv2fBeZjEBYZc24RG7PYg7pXZrpOufuEQ380Pn 7keXPQ3Xr54Vga4E5rvj30X9Irnr5vz3qhN4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Q1iNbE7b2UYUJKQIqBMPbPcIDxffIQfiNgT2DyF9Ne0=; b=aWUPwQ8SSiq8RDcNQXfpSkc9IKdR3ckXswckr4svBKl6FWTF9Ykcs92zHfCAhyQZM+ lX5kHEItvn+MptCwYXToXe4aO2ZQiDE5Y57NCe3InHQhhow5QdgkXCJXX82e1/qJ/LZ7 yJ15MAu2i1KFzUYNJCsfictoqimpEahBh4Z8zmvJAlxPH78kP1sFHN3FwESMShGZ7k98 +qZShCe8mcVNPmllPRxZ8iaQKIrP2ft0y1hE93VluvpPfgi6rPtFRnMN7B7KiCkU4YcG aU8uXuFvd5+1BtuBFV2Rh3wlWrdmzt5Tso1lkJe2DuSQ35n4yLZHCk4nWl4G+msyX747 /ZZA== X-Gm-Message-State: ALKqPweLFAvlhOPQnbSI/d5MevdGHil4RaaG/PKpBUUszX82d3wTdO6P QLQzmoMhprhUq9IcFE6sMMqPWRirU3I= X-Received: by 2002:a62:6c87:: with SMTP id h129-v6mr8371181pfc.179.1527806961171; Thu, 31 May 2018 15:49:21 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id t3-v6sm33385584pgs.91.2018.05.31.15.49.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 May 2018 15:49:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 15:49:10 -0700 Message-Id: <20180531224911.23725-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180531224911.23725-1-richard.henderson@linaro.org> References: <20180531224911.23725-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::231 Subject: [Qemu-devel] [PATCH 5/6] linux-user: Check is_hostfd in mmap syscalls 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@linaro.org, laurent@vivier.eu, evgreen@chromium.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b98125829b..d7513d5dac 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9605,11 +9605,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, v5 = tswapal(v[4]); v6 = tswapal(v[5]); unlock_user(v, arg1, 0); + if (is_hostfd(v5)) { + goto ebadf; + } ret = get_errno(target_mmap(v1, v2, v3, target_to_host_bitmask(v4, mmap_flags_tbl), v5, v6)); } #else + if (is_hostfd(arg5)) { + goto ebadf; + } ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), arg5, @@ -9622,6 +9628,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #ifndef MMAP_SHIFT #define MMAP_SHIFT 12 #endif + if (is_hostfd(arg5)) { + goto ebadf; + } ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), arg5,