Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5967954pxu; Wed, 23 Dec 2020 09:45:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJylK0UshDh+mgHcdHhr+vgxEjB+hiqwnz/tOvbacK8ihPdJDOZ1xNh5eOdX53IjOfOjtxYr X-Received: by 2002:a05:6402:41:: with SMTP id f1mr14586296edu.286.1608745554203; Wed, 23 Dec 2020 09:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608745554; cv=none; d=google.com; s=arc-20160816; b=Ram8giR42qIWOf0ZCSQpGIz+feCywI+FYXrgF9vFspH4YTOGQPuOSz3zyMCpHMqIoX tHAaF8VztsyPHLs/MSt1U+AZHKNPsYQcmAr+6Y46GxaBu4movo+Hj1QKOrW9V8f+QP90 ZwleuFQ1LxNFNQaaNF6kKxtlLjCTjL/+Ev7hZj22aYCuVNWR6Tnroh51W7x/CEE3rr0Z hc1Tbds7+aAC0RGDUKE11y0rjjBcW2f01olo3B34/8/8ojLLswMiDFCMXUEqJXFC1aJX bgO78z8GMIMVBJ2oqAPI/Nejnsd2yMAVhSCeE/ezJOXrFg3r1NYdqpyq8x3N6/yxgvhc gFCA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RD/U/Eq/ovMUKB5R5We/MH1f5iTCO1C0AjtDCf1uKaE=; b=t8ztWe/cRYbz2Ox4uH1xfwP7dYBRsU4pDuu9AmKHc1esyy16F/gYYHY2t2MfAcJaAa ZYn0eDF57xQtu9I/ggbt/JFsGfnjv2SuGRFJztrZltQLqrceeimrOFFEv3Fk+Jt9Jsqq vTa+oNbJ3BV0XISoGRPnrXVHLv1DoyDcIr6bpkHGyLahVKjYpen3PQgoJeYGweZae9+0 ENxca2CLk/7AUGNSVxSAKvO8sA1k2i/+tAJiJPGlDgLsRfOU73T9juLILN1FkLv/S2Dh +bP8hUQRjEUDFgn+Pfq/rh6sODHIzn1x1KeYFt+IQEfOKjTiD5HmwP/cuWWsbUjEp4BZ tR/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=KAuv5gQ3; 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=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n17si12226959ejs.423.2020.12.23.09.45.30; Wed, 23 Dec 2020 09:45:54 -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=@alien8.de header.s=dkim header.b=KAuv5gQ3; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728137AbgLWRn2 (ORCPT + 99 others); Wed, 23 Dec 2020 12:43:28 -0500 Received: from mail.skyhub.de ([5.9.137.197]:39474 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726424AbgLWRn1 (ORCPT ); Wed, 23 Dec 2020 12:43:27 -0500 Received: from zn.tnic (p200300ec2f0de600b74d534b1676c98b.dip0.t-ipconnect.de [IPv6:2003:ec:2f0d:e600:b74d:534b:1676:c98b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 6CD311EC04A6; Wed, 23 Dec 2020 18:42:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1608745366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RD/U/Eq/ovMUKB5R5We/MH1f5iTCO1C0AjtDCf1uKaE=; b=KAuv5gQ3YhP5hGdTshMGlu6eFW4yO/CozVbypFvQZ9waWO+ouYD1JZJ+3RO4U6+ciBJX33 qhUKmmp038Se+7YaNzR8rdr9V5auV4qKpBbpmi0ctNGbe288K4Joi3Y53hfXCtQL9/DXFF PzMJWpg7+PGITupNhbj1UYlpCHPamk0= From: Borislav Petkov To: Andy Lutomirski , Masami Hiramatsu Cc: X86 ML , LKML Subject: [PATCH v1 08/19] x86/alternative: Use insn_decode() Date: Wed, 23 Dec 2020 18:42:22 +0100 Message-Id: <20201223174233.28638-9-bp@alien8.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223174233.28638-1-bp@alien8.de> References: <20201223174233.28638-1-bp@alien8.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Borislav Petkov No functional changes, just simplification. Signed-off-by: Borislav Petkov --- arch/x86/kernel/alternative.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 8d778e46725d..ce28c5c1deba 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -1274,15 +1274,15 @@ static void text_poke_loc_init(struct text_poke_loc *tp, void *addr, const void *opcode, size_t len, const void *emulate) { struct insn insn; + int ret; memcpy((void *)tp->text, opcode, len); if (!emulate) emulate = opcode; - kernel_insn_init(&insn, emulate, MAX_INSN_SIZE); - insn_get_length(&insn); + ret = insn_decode(&insn, emulate, MAX_INSN_SIZE, INSN_MODE_KERN); - BUG_ON(!insn_complete(&insn)); + BUG_ON(ret < 0); BUG_ON(len != insn.length); tp->rel_addr = addr - (void *)_stext; -- 2.29.2