Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3042050pxp; Mon, 14 Mar 2022 09:39:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxV3Dzi/LiLSJXsBmC8v/AIzxD9dQsam47KbY+ZizgRZfDQ9y41k4W3FGcmEY4i2Y8rINBq X-Received: by 2002:a17:902:9b96:b0:14d:b42c:d4d3 with SMTP id y22-20020a1709029b9600b0014db42cd4d3mr24137826plp.33.1647275957201; Mon, 14 Mar 2022 09:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647275957; cv=none; d=google.com; s=arc-20160816; b=vsqwJq2Vd+pr0WInDmrDC0MHTUmQXJ4l+Fp9kSCbKxlXg0DUi5vxgLhnRV8bcUQ8ri L1MoLyZ4SLj34IjuUNL1qGhtwzIJFGtvRqV43+X71roAWqFpEqckZ/Qb8giI/zRxUCsz PJh5SHN5+Hc5pRq1UJQph23bu25j0EC0DyONdYq+QsMeqqljA7tWpNKLFVX+nNr6jprU bqvk154x4BuSQTfBWFy3HysXwZuPULP7OqHAdwoz3LLs9tOUBH5aYwqbs/dzirRmJaOn X2DJoJ3E/uorYRtzbW0585UOXhDqgMrInhDuig6oJGqLJFW/SH4QfkugfoLGyL/paWDo Z2TA== 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=1fA/+QQi7f1lzOq6Xkjx8vcAueTjkhW2MIclx+IMYdQ=; b=RyyVo4TWMvsE7dyizJU9pCOVxfEF6dQtZ5iKkkC4q3NMdKHI6SjJMbd20wsZ0uD0S9 Fzo+Gt8/wsmDYFFHRGecqAcYqVTRwRXV5A1+zMkocMHKvo/ZfdBFA0u1L6yzmCLgebJ6 JnoJm85s/WztSWXNysHXD68J2dlFQt+NF/PBqWg+vo88ndwifg9myL9ZPqhmHVRxzNMG EQVz7VB4Ve/hYuHKIxtNcLl5fYJnE0+t4tEfhRNnxMvuQTvzXGqCmEQIJpUkCgXHUahM zBr0+0XrjIcj5yL7LH28w2etHeXT3vlCp5GbPNVTgiyfjhmYYi96wzsNDj79vuv64Cwo hOYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ASnQA3IY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f71-20020a636a4a000000b00380dcee6d8csi13204789pgc.169.2022.03.14.09.39.04; Mon, 14 Mar 2022 09:39:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ASnQA3IY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S245690AbiCNMdk (ORCPT + 99 others); Mon, 14 Mar 2022 08:33:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243962AbiCNMVZ (ORCPT ); Mon, 14 Mar 2022 08:21:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E982413D4A; Mon, 14 Mar 2022 05:19:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 643EA60B04; Mon, 14 Mar 2022 12:19:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47AD8C340E9; Mon, 14 Mar 2022 12:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647260378; bh=Oo27dpLiqZ3PTtHat/NkqpMWmU206kpSLhFIsj6g4OU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ASnQA3IYJ1c/gbIiqm6cTQlCB/pFjzKdOp7qLKD2txTFp9azXR45DzeoLm+IKi8lG nQ3jbzYHYVN37byC/AQ/CFkpdZg0a7sq6LAmYALcaxQDDLdixlyTJtf3vt/3njfAVl ouKdnjYv2O1qCNUHtbF4rPZubaSfUEZOLWzGnMvQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Borislav Petkov , Miroslav Benes Subject: [PATCH 5.16 115/121] x86/module: Fix the paravirt vs alternative order Date: Mon, 14 Mar 2022 12:54:58 +0100 Message-Id: <20220314112747.322871288@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112744.120491875@linuxfoundation.org> References: <20220314112744.120491875@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra commit 5adf349439d29f92467e864f728dfc23180f3ef9 upstream. Ever since commit 4e6292114c74 ("x86/paravirt: Add new features for paravirt patching") there is an ordering dependency between patching paravirt ops and patching alternatives, the module loader still violates this. Fixes: 4e6292114c74 ("x86/paravirt: Add new features for paravirt patching") Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Reviewed-by: Miroslav Benes Cc: Link: https://lore.kernel.org/r/20220303112825.068773913@infradead.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/module.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/arch/x86/kernel/module.c +++ b/arch/x86/kernel/module.c @@ -273,6 +273,14 @@ int module_finalize(const Elf_Ehdr *hdr, retpolines = s; } + /* + * See alternative_instructions() for the ordering rules between the + * various patching types. + */ + if (para) { + void *pseg = (void *)para->sh_addr; + apply_paravirt(pseg, pseg + para->sh_size); + } if (retpolines) { void *rseg = (void *)retpolines->sh_addr; apply_retpolines(rseg, rseg + retpolines->sh_size); @@ -290,11 +298,6 @@ int module_finalize(const Elf_Ehdr *hdr, tseg, tseg + text->sh_size); } - if (para) { - void *pseg = (void *)para->sh_addr; - apply_paravirt(pseg, pseg + para->sh_size); - } - /* make jump label nops */ jump_label_apply_nops(me);