Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1605227pxu; Sun, 6 Dec 2020 01:13:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlX6/XjF4Wh+P+eyyyGY8NMcxZQtNxtWte7qvFmi3/xZJKgHMFIGx17CklXnQUkavzmEXY X-Received: by 2002:aa7:c886:: with SMTP id p6mr15571869eds.352.1607245985836; Sun, 06 Dec 2020 01:13:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607245985; cv=none; d=google.com; s=arc-20160816; b=LLeTPzJMR2VPES73GZUVlz0FhOkL06BJOxiioG6IE0VG5j/ebLe2R/TDGg9z5obj8p 4jp809EM5MR+C9OzhzgxHeR0HudwBDAz6SlZN1qaE/uE0vXsfaS1VDloeGArUOuVY0w6 LaE434pDM4govQ1i95oXD5ZzhSfD/LHNc9gUuvj/OV5z7KQybuC5s76u3NbN8vpGcffn ZAk5uz86foWEAxFO2tXUA7Ogl1wWV3DGhIxKxJYBxrKRCU3vwGCF5+Y7wdZ5rVDhV8Ky ZtNxfvN84CYuDCesFyXsOONID4HM1GJOvZ9fTk0844T+Iu4K+iuqDjqJKSxPPJNYwzrp zGAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=7XIcmMDqZP+StD6WMSScIteYahFlEKzsPdt6JyXYW1U=; b=sjyaytHN0PR5aIyok618w/SWOa+VP5tkDIAKnoZ/3YaBZHOV6x9jGgcJi975wdX4FL SjVnEnfd1q3y/KZlLNA/Z2t4GQ52D8iScce8jyxDWfMAhx+WGODyZsLc74zjk1KirPEa 9HC1dgOxmcK49+efFvK2jH9EffsulcFGT6qUIlzQbXLjBgkXxZ7jj1HHDncoYvPuJOYG S+6YIuYBk2QzLqq9Pa5jZA4vvP0QCXUDzLTWfgQLOBMdYbE46/QcIR6OLG0dwGUXqXjG 92Xt/ZQrnYsE/ee0OxwuUj/XuPNOcY42olVNuD/Hgb9Oy2BN+7QGoso60YpZcElzELw1 thpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="U/GIY2TB"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d17si7541192edv.208.2020.12.06.01.12.42; Sun, 06 Dec 2020 01:13:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="U/GIY2TB"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727841AbgLFJKT (ORCPT + 99 others); Sun, 6 Dec 2020 04:10:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbgLFJKO (ORCPT ); Sun, 6 Dec 2020 04:10:14 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07659C0613D0; Sun, 6 Dec 2020 01:09:34 -0800 (PST) Date: Sun, 06 Dec 2020 09:09:30 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1607245771; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7XIcmMDqZP+StD6WMSScIteYahFlEKzsPdt6JyXYW1U=; b=U/GIY2TBUYfhca6FnFMzF7a+4GS8iQjwXLHxMFsyfASJ2tfWitBNdz7CFtJ2i1pNocO9/I bHvexH6GJuCHryDMv+JPl0iJUXtN9bELvQsQ7Je/7snLWDHW5vkL1LXpo+9cg2wdraR/EW /GYP69rCft/pKre3ODQsk17Vx1gr+rySAEDuOoDb2AcW3BImi+v58ZJJeAAXxdgFS65xDy CAIBEehQ/Pue8ZaW1GZX5hW8VsRw1ck+X8oI8O5DhWOByfWmZ36XePVELV8SVZdTgCo7RG VYoKLZndLFCssNvXKt0JG7yNqX6as6YWrYjC3i6PXcSXiubEhYI64a9gqX9Y/g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1607245771; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7XIcmMDqZP+StD6WMSScIteYahFlEKzsPdt6JyXYW1U=; b=81pcTWM4u1eK+0sjNZscGEWnbQsOrRX3WoLx/qCxkZIKAVR5+MCsmocsobkZ2VTvfdLRUm hHaL71oduOKWpHCw== From: "tip-bot2 for Masami Hiramatsu" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/sev-es: Use new for_each_insn_prefix() macro to loop over prefixes bytes Cc: syzbot+9b64b619f10f19d19a7c@syzkaller.appspotmail.com, Masami Hiramatsu , Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <160697106089.3146288.2052422845039649176.stgit@devnote2> References: <160697106089.3146288.2052422845039649176.stgit@devnote2> MIME-Version: 1.0 Message-ID: <160724577024.3364.5782296021920253763.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 84da009f06e60cf59d5e861f8e2101d2d3885517 Gitweb: https://git.kernel.org/tip/84da009f06e60cf59d5e861f8e2101d2d3885517 Author: Masami Hiramatsu AuthorDate: Thu, 03 Dec 2020 13:51:01 +09:00 Committer: Borislav Petkov CommitterDate: Sun, 06 Dec 2020 10:03:08 +01:00 x86/sev-es: Use new for_each_insn_prefix() macro to loop over prefixes bytes Since insn.prefixes.nbytes can be bigger than the size of insn.prefixes.bytes[] when a prefix is repeated, the proper check must be: insn.prefixes.bytes[i] != 0 and i < 4 instead of using insn.prefixes.nbytes. Use the new for_each_insn_prefix() macro which does it correctly. Debugged by Kees Cook . [ bp: Massage commit message. ] Fixes: 25189d08e516 ("x86/sev-es: Add support for handling IOIO exceptions") Reported-by: syzbot+9b64b619f10f19d19a7c@syzkaller.appspotmail.com Signed-off-by: Masami Hiramatsu Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/160697106089.3146288.2052422845039649176.stgit@devnote2 --- arch/x86/boot/compressed/sev-es.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/boot/compressed/sev-es.c b/arch/x86/boot/compressed/sev-es.c index 954cb27..27826c2 100644 --- a/arch/x86/boot/compressed/sev-es.c +++ b/arch/x86/boot/compressed/sev-es.c @@ -32,13 +32,12 @@ struct ghcb *boot_ghcb; */ static bool insn_has_rep_prefix(struct insn *insn) { + insn_byte_t p; int i; insn_get_prefixes(insn); - for (i = 0; i < insn->prefixes.nbytes; i++) { - insn_byte_t p = insn->prefixes.bytes[i]; - + for_each_insn_prefix(insn, i, p) { if (p == 0xf2 || p == 0xf3) return true; }