Message ID | 20210115224645.1196742-7-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show
Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp272986jap; Fri, 15 Jan 2021 14:54:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjQF40DUSRsCaatduQ/Wedr7+CsOQVKKefZq+YBbJp+dRx5z+rpC3XKqLWzN8QD/eyMR43 X-Received: by 2002:a25:497:: with SMTP id 145mr19992592ybe.275.1610751249404; Fri, 15 Jan 2021 14:54:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610751249; cv=none; d=google.com; s=arc-20160816; b=aNENPqEf8ai+T/PsgxBqID5Xv31S86lnfKFkBWWutvsESlTO+NoiK7fk2IzH3Z6+db BVDD71jed19w3/RGhz/YXNQT1UVKlSSh5baj1TJtfZKbzK3blx+3rjN7tClCl9YoDHrf aAyQXwJPJ2qw/ifa7bDTZDf5SCR5o30DIJL+R5iqZclMlvWJ93NBG5+Cu4y5EkkvOv04 grklkjFVxB9WWGPyLFaVyLudTtGrFJnoaGbCNNgzcAGkzSP/m91Dw0aHSKqX+0/5Z4p+ TvcrBqLOHCN28jXRjOG9/23f9kul350cdQpN0o+zekK4WxiK7ZG2zTpyjsE4nReuUTY2 G+ow== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rr4uhte3iLsKjX8Cbli6gBSl01cB/KM2FqNYctfYPe4=; b=OxTkt0sTSz6EWWSk3FsnT39rCCOrFd21BfxViZhkD6x8O2GrQUejIdvU5G2J7Ephvu k3x5BRiEt72iur9ZvBAWbfVV6dLBv5N89v1+MUDKbK7FtvMyZO4zPBaYroFqwnjW2Zaw twNEAoL1aFcagBU8W+T5jYzTPCv2p9loS0fZGvcu/arnFvlzSxoJkivjXaFiee0sEDr0 6+YHjYrCZNS1ITsc03c7dUYwU3296n8cMOYoa7k6YcZ2wJJ++ZISxnuoi2b1xEUi2WRn o/XmvbgYdHZRvGXlHCWGbAJhEBjoVPQinflX3GwxiwRV5miCE3o/wSaIrZZQZNjN9Y0q 1RjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZwiPCxB+; 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=fail (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 128si8134061ybd.172.2021.01.15.14.54.09 for <patch@linaro.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jan 2021 14:54:09 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=ZwiPCxB+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40868 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 1l0Xyq-000381-Tq for patch@linaro.org; Fri, 15 Jan 2021 17:54:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53726) 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 1l0XsC-0003ZK-0F for qemu-devel@nongnu.org; Fri, 15 Jan 2021 17:47:17 -0500 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:42969) 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 1l0Xrw-0005EB-FJ for qemu-devel@nongnu.org; Fri, 15 Jan 2021 17:47:14 -0500 Received: by mail-pg1-x534.google.com with SMTP id g15so6927498pgu.9 for <qemu-devel@nongnu.org>; Fri, 15 Jan 2021 14:46:59 -0800 (PST) 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=rr4uhte3iLsKjX8Cbli6gBSl01cB/KM2FqNYctfYPe4=; b=ZwiPCxB+pgxqBSVhiKyzXLXxQL2ZxeJzOVekdmh0Png2yTdh5LHtbGJfe4xgh5KT5j MONKrUNjyAZIo/Q1APKbecM5C3a2XWQ9n1SkdQYEIAjD3by8a1EfLqIC78kqEvzPy2Iw X/eFDlBpD3YCYzZa19NwkpOOx/Y3yf+HWoCgmgKo2BTMP+Trc3cJb3vfouNGqfVOHF2Y J5j3S2NZgFFGIVUnvR5Mzy56uZgnFXNcA5fWhPpPP37Eb9xSnyHYOAKi9+o1+1smjgD0 z6HBA6xwvzedCCq9CzuCJnhO++Kf0zAKKG6opn1QJNchgzU6sBesjQK/wu7znGiPrZRK 7YOw== 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:mime-version:content-transfer-encoding; bh=rr4uhte3iLsKjX8Cbli6gBSl01cB/KM2FqNYctfYPe4=; b=fvocsuirMti1xAdwBkMBLcM61BeENGLSNeVZOIOjcOsSiWEtEqyYxO8jYhUEbwu78l E2qFSku8qxDAAXgugjDS2CCOYmdJW+tztxMSHQOng6Zw87ihn6qxMVw6JBK395Ha5g0V jBtvDNVRizfendt1Mja/Y/mo6HTrCSXtYUYa7mSRWhu3T9EKUaHAdm1UYDCRYePHrTy1 XJvnbveKvMT7iK5aez8mzB/dLEAw+Bzfc5EENWyo3qmv2Dw+hAQ1YMESt9pdDR5m+K2Z sr9qaiQLFHfk/VZHIdsKl7V/5i7japDm43ka539/3EgfZCXMhCCHsaDU5DXIe1YNLHv8 D3PA== X-Gm-Message-State: AOAM5336ioucxHpnVxox26ZmbXxl2jI609vOkfLjBaF3loccH5vSy4dp +4JsawQIcSguPqef4av2lBYl0+PJ2wleX7OD X-Received: by 2002:aa7:9706:0:b029:19d:a2c6:aeb with SMTP id a6-20020aa797060000b029019da2c60aebmr14865467pfg.36.1610750818505; Fri, 15 Jan 2021 14:46:58 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id s13sm9521700pfd.99.2021.01.15.14.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 14:46:58 -0800 (PST) From: Richard Henderson <richard.henderson@linaro.org> To: qemu-devel@nongnu.org Subject: [PATCH v3 06/21] linux-user: Check for overflow in access_ok Date: Fri, 15 Jan 2021 12:46:30 -1000 Message-Id: <20210115224645.1196742-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210115224645.1196742-1-richard.henderson@linaro.org> References: <20210115224645.1196742-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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> Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+patch=linaro.org@nongnu.org> |
Series |
target-arm: Implement ARMv8.5-MemTag, user mode
|
expand
|
diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 534753ca12..a0f670832e 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -489,12 +489,19 @@ extern unsigned long guest_stack_size; #define VERIFY_READ 0 #define VERIFY_WRITE 1 /* implies read access */ -static inline int access_ok(int type, abi_ulong addr, abi_ulong size) +static inline bool access_ok(int type, abi_ulong addr, abi_ulong size) { - return guest_addr_valid(addr) && - (size == 0 || guest_addr_valid(addr + size - 1)) && - page_check_range((target_ulong)addr, size, - (type == VERIFY_READ) ? PAGE_READ : (PAGE_READ | PAGE_WRITE)) == 0; + if (!guest_addr_valid(addr)) { + return false; + } + if (size != 0 && + (addr + size - 1 < addr || + !guest_addr_valid(addr + size - 1))) { + return false; + } + return page_check_range((target_ulong)addr, size, + (type == VERIFY_READ) ? PAGE_READ : + (PAGE_READ | PAGE_WRITE)) == 0; } /* NOTE __get_user and __put_user use host pointers and don't check access.