Message ID | 20210128224141.638790-7-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show
Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp1670292jam; Thu, 28 Jan 2021 14:57:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJysRtOeAGzbJrD+RNMKl4FZHIToO2P7L0hZZETFnZrZ+2Zr/dfdDrLjRKPcoujxbFDtEB+l X-Received: by 2002:a25:c901:: with SMTP id z1mr2131624ybf.497.1611874653217; Thu, 28 Jan 2021 14:57:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611874653; cv=none; d=google.com; s=arc-20160816; b=WDPXSRfYUYrld9aDe3YOEe9/akXquHgsFAZA3kW9AYo8Ypj769qIbI8FH3pCbdG9We EbLqOCes2ICF+HhSR8L/phTbHvSo/XPVobCXHTq3UVmg/+CVAhCuL362u9LHze07nY0d d2x0hfPOh1QbzzmzZx+421YKRqUeHPrU44LV/yU8hOi+4hYImkwYEOgh6M+uoAFwf8pO B7cZFDNexumrUeEx59x29fZKwzaHH4fkuiacOPO5EqL3Aa5HqCv8MSZ24YcoWJQP3MV4 fidfnSXRGdX5ovlePqRFJRn3kjuPcKiZOtQMnLcNR2MyVKCxZozXipAIN8ltF1bH8iwT Is4g== 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=yAOD8rB2c9GoNvNcKMZwjdplIAr1RvdqOJ4SbnIjxU0=; b=d0Rojpd1rluHiZe5HQttA8U2sTG+WuRpyRxbEuHjM4rhE0h7JQ4OGvNdQMKQp/ZCiH drh2ibbVeE6X4+mxKTsOYT9viaXgl/MgGl14Yz5FmHv694FzmWjDFbamcMIgDzNhmgky bTi3j1ufWaFYwYRdiOxDQbXgo5gJiw5lDxmil+wMgbpEoe/A/ocjQzc2UgYxQS/LDOFP 8g7kMFp7gB0jnz55qFYBuE0T9DuvPd5c/qA5ZSYWu9HfjA4viDUHr1n+p7Lal6lF+w9R q1DtEBnvZ/L2QxNLNLQrBUcdz3mPWELA+BviqW0kCarLZ7p3CNYIWlBbSdi7blmrreLT zQXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="R/F3YyFC"; 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 d2si3728453ybo.430.2021.01.28.14.57.33 for <patch@linaro.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jan 2021 14:57:33 -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="R/F3YyFC"; 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]:52044 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 1l5GEG-0004Ee-Ls for patch@linaro.org; Thu, 28 Jan 2021 17:57:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33116) 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 1l5FzQ-0005XT-22 for qemu-devel@nongnu.org; Thu, 28 Jan 2021 17:42:12 -0500 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:40926) 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 1l5FzC-00086a-6n for qemu-devel@nongnu.org; Thu, 28 Jan 2021 17:42:07 -0500 Received: by mail-pg1-x52b.google.com with SMTP id b21so5276650pgk.7 for <qemu-devel@nongnu.org>; Thu, 28 Jan 2021 14:41:55 -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=yAOD8rB2c9GoNvNcKMZwjdplIAr1RvdqOJ4SbnIjxU0=; b=R/F3YyFCc8P4RFEKcagFfxMLOvG9vlxwyTklHlikzFx6WPnuKQWec2SILIg7td2fzU siH2mWYc7CCMnj+eJF0B1Vixgveut2jo7Gkp8pTi0j65BJQwNvY9Wk1i8kSpJCCRitxo YXfGFUeZ+PoJHlJLTCfHOP5unBeerJ+X9jd+1tl0ifjkhOGWY9XaQ8PAgK3H5c78Ij1a qDLjKceXJ0esgipHREPO4UGuRZ+VzXEpjn2xkifg7SLO2dLTtzV/ps1Z3s+Phn47H0pO OHGfGN7qBSirTQtcKvERMM2v2c77rPhuQ6cdWl4FTgjZQJi+QSCULyeZFwICdhAGjaLa JjCg== 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=yAOD8rB2c9GoNvNcKMZwjdplIAr1RvdqOJ4SbnIjxU0=; b=Tz8GLrClhmxVdHXzU8PFxcMKpOkxLgsm+K+a0qyIdBthhPFewhcAj9QHXbGG9DF346 S8aG0Y48qWwCms2596iDuyqHRU7y6AYnCcREQDfX/iNyuts690ZLwfVn+4KLaOVEoVm0 LzA0OamRo6lw+QSA/H6TKjxPX2gs8SuzNfjAv9sPOe368AyUO2/p/T11UG85yf94iNnv kkxNTeoY1khzRZAI5YBI4q6n93WWhkzsG5xMGrA830X6q75nXw6Qz1NZdGng7dQquQgX EuM+j1hUNISd5VTvv2URhQHCr6e6pIVxkAYxQAlDuVbP5B0TKHnT6Jhtqct+kA4lx50S Z4Sg== X-Gm-Message-State: AOAM533KrQIEZf+EjiD69HPugc+qW7l1dZFj+bjgtt7PXq86ZBEYwQ4p R96nyfT9c2LXonqJ6oe4CfkDdlW3d/ppyGQD X-Received: by 2002:a65:408c:: with SMTP id t12mr1532592pgp.157.1611873714714; Thu, 28 Jan 2021 14:41:54 -0800 (PST) Received: from localhost.localdomain (cpe-66-27-222-29.hawaii.res.rr.com. [66.27.222.29]) by smtp.gmail.com with ESMTPSA id m10sm6042358pjs.25.2021.01.28.14.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 14:41:54 -0800 (PST) From: Richard Henderson <richard.henderson@linaro.org> To: qemu-devel@nongnu.org Subject: [PATCH v4 06/23] linux-user: Check for overflow in access_ok Date: Thu, 28 Jan 2021 12:41:24 -1000 Message-Id: <20210128224141.638790-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210128224141.638790-1-richard.henderson@linaro.org> References: <20210128224141.638790-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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=unavailable 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 17aa992165..441ba6a78b 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -491,12 +491,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.