From patchwork Thu May 31 22:49:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137448 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp211025lji; Thu, 31 May 2018 15:54:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI6fUUu5jYaA7DWvA9Xh1/FUpHRoKWLvgfaklivIxRRj2fUP0o4q5u0M/E8e4lb3AtnTNGY X-Received: by 2002:a0c:a3c3:: with SMTP id v61-v6mr2930529qvv.99.1527807273725; Thu, 31 May 2018 15:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527807273; cv=none; d=google.com; s=arc-20160816; b=x/aaJJXhuA8XIqcGQ759pT751yE0N3Shr0yDwIHrur69upJ7IvIyp0Zpn/VDqLdO2x BTReu7ni1CcrJMG25Y4RMsPCqeteUBX8mBwGA5U4K1TYf0cS8zzHwNRCggp8jK6mUhPr I1VFKTJtuX4lUTzzuctHpiFIZhxyaM21wrqhAmzpm+57AxtHZRvU9fCZ3cR4RWqxd3ne M8lQ2jljKi7nuzyTUT/IFyJ0CLE9G/RqytamiYk2imrWMiBiIQbewvrcd5LFqMJYg1SC Ad151i7KKfFf07/wEOndcJj1Bzhlk012V7E4UvvyPgRlFXRxnXROm8YrRGr9ZbvgS0pF qHyw== 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=vgByVcF4sTG4UIGoDfjdQmMRjmxXVfAO4cyzhWgy1pQ=; b=MKRhnOb3zWePxEeg5ydxZOWt89ebOUiB/4JI+TmhL8H8z/a6j1IdIjhaGru7/7sjur cpYK2Xkllv5ZnQGNIm/6GNFRLyRJraMhP5l8WZzZGQuqdGUQa/rWMbdD7QgOm0GPMmmN lRLJ/ARhNwsvsI+FJVRw6zt/8XiaOC7J72lqybYw1SbWsDFufShtNtcZmnPFCRo3SG2Z WxvZsvBZhZ32ZonwJq/piRdg+RIXhpWe5vLgp2cTOZpaJlBMpGRkMSvW5N5qgSUEMpcv O56NpmG1M6J+J4y4xybHjYJDaqtJpKCCvtWSgsZBUmkBr5HeC9oUe8TJ8/ZW0Btn1sg0 bj4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jXBJAyoQ; 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 h18-v6si2914063qvc.186.2018.05.31.15.54.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 31 May 2018 15:54:33 -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=jXBJAyoQ; 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]:46524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOWSm-0001Hm-VI for patch@linaro.org; Thu, 31 May 2018 18:54:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOWNn-0005AX-7a 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-0000pQ-I9 for qemu-devel@nongnu.org; Thu, 31 May 2018 18:49:23 -0400 Received: from mail-pl0-x230.google.com ([2607:f8b0:400e:c01::230]:47027) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOWNm-0000p0-CQ for qemu-devel@nongnu.org; Thu, 31 May 2018 18:49:22 -0400 Received: by mail-pl0-x230.google.com with SMTP id 30-v6so14074562pld.13 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=vgByVcF4sTG4UIGoDfjdQmMRjmxXVfAO4cyzhWgy1pQ=; b=jXBJAyoQ5oIb2p6Nf95rL+iLe45Ui5dtDFJzssYth2sQVfoQ16lFJK2OYXEiKO4pyT c4b/U6jOD3xenRbibE15kfrhTmzP1i/irQjmuPN0EuDxW5kYydWGnpOLgN4n0jnDlpUm 4rZFwhllXSMWxyhPkHcY7UBReii4c5Y879IA4= 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=vgByVcF4sTG4UIGoDfjdQmMRjmxXVfAO4cyzhWgy1pQ=; b=eNVhdPkhQpJxlZu+li3Le76tDLMYIMGbPBkxYXYonIw+heyJCRNG9MPYnr8hILD/TS 3kIO2EQkNJ4o44PXzkKMNYHHZ1n2slKSiMKcwbjixPnBpodtLHBL+K88OJMoSHziYWg5 RtsAxaM1UxrqF4wCy046oruYIsz5XUqTGXUc3jqCjryjx8waK34Phz8OAxD7vCqajBna 97YUvOMJdwv518j55zCOjwnkvwbXXdCKi92q75jGWEA1YAKBkU2qzrvaT4T19xHPGMaA 7HI80Vrd7Ih18Y0rAjnSqFqBTpqTMGcnsFtuRaA0Az28uTz6iGCQfKqbhYbz7NIdadR6 vuvA== X-Gm-Message-State: ALKqPwfAif36pSMH98phD+alvRGheoeHlpt8NG6Ueb0tlsZHcCb6BRR3 1NRkMmEFpKKGExQaOCTgJ568dZlXKoQ= X-Received: by 2002:a17:902:7e42:: with SMTP id a2-v6mr8654068pln.151.1527806959735; Thu, 31 May 2018 15:49:19 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 May 2018 15:49:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 31 May 2018 15:49:09 -0700 Message-Id: <20180531224911.23725-5-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:c01::230 Subject: [Qemu-devel] [PATCH 4/6] linux-user: Check contains_hostfd in select 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5339f0bc1c..b98125829b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1506,6 +1506,11 @@ static abi_long do_select(int n, if (ret) { return ret; } + if (contains_hostfd(&rfds) || + contains_hostfd(&wfds) || + contains_hostfd(&efds)) { + return -TARGET_EBADF; + } if (target_tv_addr) { if (copy_from_user_timeval(&tv, target_tv_addr)) @@ -9392,6 +9397,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, if (ret) { goto fail; } + if (contains_hostfd(&rfds) || + contains_hostfd(&wfds) || + contains_hostfd(&efds)) { + goto ebadf; + } /* * This takes a timespec, and not a timeval, so we cannot