Message ID | 20220628045403.508716-32-richard.henderson@linaro.org |
---|---|
State | Accepted |
Commit | 40f1219a8b2f95808ed5a18798dbce1b57fef211 |
Headers | show
Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp478939mab; Mon, 27 Jun 2022 23:38:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uuQpl02cSbsmc2vZz6TeY8arL9Am6bI6cEB+9dPirmBk78hD8yt/x4wRnrRlX3H9zE+jhi X-Received: by 2002:a05:622a:1a93:b0:31b:efe5:8b6 with SMTP id s19-20020a05622a1a9300b0031befe508b6mr1422259qtc.347.1656398304638; Mon, 27 Jun 2022 23:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656398304; cv=none; d=google.com; s=arc-20160816; b=WmizpnAQqROKpswAMS/NjLl8NMfema5KlXR3TZSfvw3Vn+r5fMswnoorJX1PzmMTog QE2dmeIC2qwJvwLSpL5aF8IYigvTviPIPTlBEt76RfEZjZGHb5PxSq/GA/ahd6Z2Il+I iLIp8sB4SVHcUK1gyFKOrtiZFMyYsZuaC1NsH6PNu3eSUXShT+pLrNucQhAAN4lPVown aidFIMCu3K0vr02C+UcfunGpEhtQ7lCOKqR3dMMtMvKx3/Hy5FqVVbqAecceTj6zDbwG p24FKbAHu0ue8stng0Cq0pF3mVwbOx+MgiWQK1RmdhC5GrZaRPoB8BjYUc7EOybaoO9t l7bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BeS68NN3ViIVt950y4ivDmAvcVcb3oQ70+IeLQ73SLs=; b=S7z1Tpuhnk+2T8aw6RTgIO2oRE2ClbF44chPcer953jvLCEsnFJsGhFjgkvyIlL9uX YKoeWQps17W/hl3V8wrM72NYEw/j5GIWBowA569jncrp/eTq59yc5Y63I6mNyPSVxeqB d28E7Zhzeq0sZhcX4cAtpHHckrv3RxgEGK4XRokCWl4xwbMmz3O+hiyyCMFwemNdoirc mqbQzFVwyCfAJHDaq5R+dmUv/90C1eiXzcXLn/3Yi5ApzMp9T3K45UhLssubIe2yJfKn 7Kq0uI7tI07HAfP4yWohqTaCFAx3xN81F6XejRwgEFJ0erkBur3A+7pXkZoX/oy7tXNX 10nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jwGBVqhw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: <qemu-devel-bounces+patch=linaro.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c9-20020a05620a11a900b0069c7ad4331bsi236796qkk.571.2022.06.27.23.38.24 for <patch@linaro.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Jun 2022 23:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jwGBVqhw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces+patch=linaro.org@nongnu.org>) id 1o64rf-0003BJ-SU for patch@linaro.org; Tue, 28 Jun 2022 02:38:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>) id 1o63G2-0003WG-BQ for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:55:26 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:46714) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>) id 1o63G0-00009v-2G for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:55:25 -0400 Received: by mail-pf1-x42e.google.com with SMTP id a15so10914775pfv.13 for <qemu-devel@nongnu.org>; Mon, 27 Jun 2022 21:55:23 -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 :mime-version:content-transfer-encoding; bh=BeS68NN3ViIVt950y4ivDmAvcVcb3oQ70+IeLQ73SLs=; b=jwGBVqhwFq3YqIFYlA19VFZ78Yp0mFy6lQ6e+XCYwsX1PsDtwfbOXDJRFKVWVLITZb oTPR4PG4WTFCisEr6CpNzQS9WUC1zxuz9/pDOdt9IU7BQ0ED/G4qcr+VIJtwtTPlcDZm TUMBwFYkT0T+Plcd6ib438HF2ABJ5hEarlAz/YuAQdbMWOiE6ILsaWtuUh9X9EP5+JRc 1ODQ2WuzcqW7jLJQuWqpkz7I2QB+RaNremaXTwEzU2UksmTcZLsIpPf+J7lVg0463ZKL XAoBhJhwX/JnsmLxSYKZAbEFbKxp0p4JxkbxwBz7YsZwSCn7N+e44jBXSaHNF8fWkE7v ADUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BeS68NN3ViIVt950y4ivDmAvcVcb3oQ70+IeLQ73SLs=; b=lsTmC8aL7UEOwAdhPEvf9nqnb1jEtJXwmgQ13Asg53dpIXyLzCYmaUW9B4Qy0KqUrz QK0uGv7FRrc5zRVD5IsHdpF/dLwpFOHgc/zvqD33+SZnM5v/uF+VOV5qS5hdhZEx6lNq HdxyqNmiylRc6PYivmtZ9ke+E+XetwzCoTia0cwtrpxcMwaBO1BzL27AKmr/TuGVc6yY HSg5adtVZIYyziMb3s0fpTYgeEnf2i/0O/B3RS+kkmeSWW1hBrRA7nTk2glA9Ts8qwQ9 paXDG3i1C2yf9QVWhGoFpfppN1OM8k7zqQ40mnuPXeOBIugTIwLUIxZ4bihzWSCSty6p ASig== X-Gm-Message-State: AJIora+cYxqRslRu7oOMU44z+IelsR9aYSHdH5xvk5A0lkAoYaIybNDI KyrW2sFiqW6Kr1AVJNnR2dd7VkETi0Ss9Q== X-Received: by 2002:a63:7d45:0:b0:40b:e6ad:8e80 with SMTP id m5-20020a637d45000000b0040be6ad8e80mr16354704pgn.59.1656392122573; Mon, 27 Jun 2022 21:55:22 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id w8-20020a1709026f0800b00168c523032fsm8073735plk.269.2022.06.27.21.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 21:55:22 -0700 (PDT) From: Richard Henderson <richard.henderson@linaro.org> To: qemu-devel@nongnu.org Cc: Luc Michel <lmichel@kalray.eu> Subject: [PULL 31/60] semihosting: Bound length for semihost_sys_{read,write} Date: Tue, 28 Jun 2022 10:23:34 +0530 Message-Id: <20220628045403.508716-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628045403.508716-1-richard.henderson@linaro.org> References: <20220628045403.508716-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+patch=linaro.org@nongnu.org> |
Series |
[PULL,01/60] semihosting: Move exec/softmmu-semi.h to semihosting/softmmu-uaccess.h
|
expand
|
diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c index 5cb12d6adc..eefbae74f1 100644 --- a/semihosting/syscalls.c +++ b/semihosting/syscalls.c @@ -283,6 +283,14 @@ void semihost_sys_close(CPUState *cs, gdb_syscall_complete_cb complete, int fd) void semihost_sys_read_gf(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, target_ulong buf, target_ulong len) { + /* + * Bound length for 64-bit guests on 32-bit hosts, not overlowing ssize_t. + * Note the Linux kernel does this with MAX_RW_COUNT, so it's not a bad + * idea to do this unconditionally. + */ + if (len > INT32_MAX) { + len = INT32_MAX; + } switch (gf->type) { case GuestFDGDB: gdb_read(cs, complete, gf, buf, len); @@ -313,6 +321,14 @@ void semihost_sys_read(CPUState *cs, gdb_syscall_complete_cb complete, void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, target_ulong buf, target_ulong len) { + /* + * Bound length for 64-bit guests on 32-bit hosts, not overlowing ssize_t. + * Note the Linux kernel does this with MAX_RW_COUNT, so it's not a bad + * idea to do this unconditionally. + */ + if (len > INT32_MAX) { + len = INT32_MAX; + } switch (gf->type) { case GuestFDGDB: gdb_write(cs, complete, gf, buf, len);