Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4724906pxj; Wed, 12 May 2021 11:46:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwN8xiTehus8BPYcHy4/jIqu/OAerf5ag0qEzEs+avdS4RQghrOw+tuIv+mbkM5d28AFBcV X-Received: by 2002:adf:e846:: with SMTP id d6mr47118203wrn.356.1620845218623; Wed, 12 May 2021 11:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620845218; cv=none; d=google.com; s=arc-20160816; b=wZlOut0A5loeoE1mSb+/UmZ7tmgM1LJ6wx0HMh/7yTSeEqhDKogClpONpw3qnEYNVU 3B0qMvZs4JaxcPH9eshmK3rxX60DFmHxr7VWmUOUnT9WLV8HPbpLuG1ekbacXxUixrvD +sa2wI+VoydoJlqksNKAbOXVT9MXlAEzFhy2/rMoGl83PWJvDRPxACty/bCeg5/FYk4I 9UOgiJu3/kZ+/5kbxXZXVRMkAmgFOQohTQVw2dNDnlk96vVtQzzP+tTFsSfqbV8Hdh9d IuvgYQoa2FVKgHvyzbE8uKbVS28Le7BRFd2Oysipo/gMO+xLmKucLWMislz1TsuImUlO XwSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CaFTZL9iQaUiyf03Ql/H9UAhZ660QftF0LgWg/lc6FI=; b=qFK6JPQTJ5H+Rk6y3J2ptOC3D4MKeDvqPtMnPu+PGAYjSP3CoOlbYwGJeuYSJiJVqJ 9/LNFHB5SdFEh4GJyyGYSb9Yng0wQNb0mBTM2At9x/aRrxzUGaZpLon+he94snYsFFEQ hmS1H9c5Pdmicj38h/EUux9rkcf2PlUKVJfUJ0I+0VErCtAAHhHXWQrqUJx47z73eAiB wpwgG1aHigw+KRtIXxCRH1R9UYtbA+dbQOiq7jGi6JfztlZGJPolxaJhyZ0kUz8UrXXA xlN6XX/Qs9jlQFmzPAGTzDHlFw1KK1a46SIZrOmtKgMLH1RT4j2iFmK29VPP9vH/dqSv yezQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=COLpOHiJ; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s6si409250wmc.20.2021.05.12.11.46.33; Wed, 12 May 2021 11:46:58 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=COLpOHiJ; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358328AbhELSno (ORCPT + 99 others); Wed, 12 May 2021 14:43:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:35790 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243570AbhELQld (ORCPT ); Wed, 12 May 2021 12:41:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EA9236197C; Wed, 12 May 2021 16:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620835500; bh=vEXn2+QEnkphoNPm6RRdHN5YvdmqZSX3NzzcoXql7Lo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=COLpOHiJfdPxEoj+/8ROgLPRGRfV7zfmsim2j/41/HRhvikIX9GY+JBfIxSqOBlmq Qdgc/PfohTbDyEIzrY9boL/kCDld3lzBLxaYS+hOpk1OCzvmK4EEDM+s90hVDii31q 6yWK7HhAEArAm0zPTFfrgapVMfsAG9B54yI4uX+k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.12 368/677] x86/kprobes: Retrieve correct opcode for group instruction Date: Wed, 12 May 2021 16:46:54 +0200 Message-Id: <20210512144849.552383168@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu [ Upstream commit d60ad3d46f1d04a282c56159f1deb675c12733fd ] Since the opcodes start from 0xff are group5 instruction group which is not 2 bytes opcode but the extended opcode determined by the MOD/RM byte. The commit abd82e533d88 ("x86/kprobes: Do not decode opcode in resume_execution()") used insn->opcode.bytes[1], but that is not correct. We have to refer the insn->modrm.bytes[1] instead. Fixes: abd82e533d88 ("x86/kprobes: Do not decode opcode in resume_execution()") Signed-off-by: Masami Hiramatsu Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/161469872400.49483.18214724458034233166.stgit@devnote2 Signed-off-by: Sasha Levin --- arch/x86/kernel/kprobes/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index df776cdca327..08674e7a5d7b 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -448,7 +448,11 @@ static void set_resume_flags(struct kprobe *p, struct insn *insn) break; #endif case 0xff: - opcode = insn->opcode.bytes[1]; + /* + * Since the 0xff is an extended group opcode, the instruction + * is determined by the MOD/RM byte. + */ + opcode = insn->modrm.bytes[0]; if ((opcode & 0x30) == 0x10) { /* * call absolute, indirect -- 2.30.2