From nobody Fri May 3 18:33:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14902919859830.3201507918186053; Thu, 23 Mar 2017 10:59:45 -0700 (PDT) Received: from localhost ([::1]:57781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr71U-0000TU-Tb for importer@patchew.org; Thu, 23 Mar 2017 13:59:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr70j-0008WR-0l for qemu-devel@nongnu.org; Thu, 23 Mar 2017 13:58:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr70f-0001r4-To for qemu-devel@nongnu.org; Thu, 23 Mar 2017 13:58:57 -0400 Received: from mail-yw0-x242.google.com ([2607:f8b0:4002:c05::242]:34846) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cr70f-0001qn-PO for qemu-devel@nongnu.org; Thu, 23 Mar 2017 13:58:53 -0400 Received: by mail-yw0-x242.google.com with SMTP id h11so24424803ywa.2 for ; Thu, 23 Mar 2017 10:58:53 -0700 (PDT) Received: from localhost.localdomain (c-73-207-178-95.hsd1.ga.comcast.net. [73.207.178.95]) by smtp.gmail.com with ESMTPSA id d134sm1933924ywb.10.2017.03.23.10.58.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Mar 2017 10:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=faILyaP6RdetmIslKhrHDwTWtqy604TFh49FJFUhiJc=; b=R8cnpQ+dtzHtR2v0nIDG1Uni/SyWP/DJhArcdb/FTXrGGrPM+iswszpPrINsHYJ8dV UUIGISYMW6zpf5hN4yDK7PzkScmI2ftwubtn1jhhjIw3BQEBbFNWYG6LBtJgOhbf63aF cTAlZWXd/oDHqcse3Omf8PsDIcIzW0r2elBOfYGm5s1yWRu/sseUmz6fP4A4tyI/BMrr w8hIEV3laIN93AmN+oWE+2piDP+uazTYQVdbuFU/ZAx0GMLelDSBMX4YEEFO0SRh2X2W 9KHd7oNnWI6cc9qg6J71cD1hz1YHJaJVxkmirvltGXpJrHTAlVmWBECLXowFeuZjbVXt gw0g== 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; bh=faILyaP6RdetmIslKhrHDwTWtqy604TFh49FJFUhiJc=; b=AX2Q7xbY/3afkNUQb7t7ocrebD6+yyR6K+ym41pnTDEi9yaFQX05oEvs/fMBzFKt+G I7tYGoQirWUxZ421rvv+AKps9TMiaPgWUQwJ9JqVGL6SgSrWkVH8yvRhACqhFclegLHC FLu2mPwNEMbzYRc/eJTLkgyXXYJJEh9jJ7pQ1+IOv+KmkoyR7JK+unozC9OdivIqYMwH 44+UVUPZ8YkujmclxPyblCFmRK4ovAZP11BIivMxH811uvj/Ua5rA3vefFPbFJrKQRK1 peazYqTDAcN0sluydYFGXOIeFMuf/xiPYi5lZp7HCUogQappPa1Cjo3F8PvKig96ELo3 nc9Q== X-Gm-Message-State: AFeK/H18pzLD35OP2NVu3Y1gSsULxvxpCDNAfzMQGAtNLdhdOGGC1nOdIKQp9eGsxIzktg== X-Received: by 10.129.152.134 with SMTP id p128mr2929897ywg.1.1490291933022; Thu, 23 Mar 2017 10:58:53 -0700 (PDT) From: Pranith Kumar To: Paolo Bonzini , Richard Henderson , Eduardo Habkost , qemu-devel@nongnu.org (open list:All patches CC here) Date: Thu, 23 Mar 2017 13:58:51 -0400 Message-Id: <20170323175851.14342-1-bobby.prani@gmail.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4002:c05::242 Subject: [Qemu-devel] [PATCH] tcg/i386: Check the size of instruction being translated 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sending again since I messed by pbonzini's email. This fixes the bug: 'user-to-root privesc inside VM via bad translation caching' reported by Jann Horn here: https://bugs.chromium.org/p/project-zero/issues/detail?id=3D1122 CC: Richard Henderson CC: Peter Maydell CC: Paolo Bonzini Reported-by: Jann Horn Signed-off-by: Pranith Kumar Reviewed-by: Richard Henderson --- target/i386/translate.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/i386/translate.c b/target/i386/translate.c index 72c1b03a2a..1d1372fb43 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -4418,6 +4418,13 @@ static target_ulong disas_insn(CPUX86State *env, Dis= asContext *s, s->vex_l =3D 0; s->vex_v =3D 0; next_byte: + /* x86 has an upper limit of 15 bytes for an instruction. Since we + * do not want to decode and generate IR for an illegal + * instruction, the following check limits the instruction size to + * 25 bytes: 14 prefix + 1 opc + 6 (modrm+sib+ofs) + 4 imm */ + if (s->pc - pc_start > 14) { + goto illegal_op; + } b =3D cpu_ldub_code(env, s->pc); s->pc++; /* Collect prefixes. */ --=20 2.11.0