Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp40059lfv; Tue, 12 Apr 2022 16:24:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzX+rB9cCb/RGjZ4ygdblVbATBzUWiOEs1fghTrgiwiUg3AsCWhujy9KDqaCnF27KPGyuRT X-Received: by 2002:a17:90b:3909:b0:1c7:9bc:a735 with SMTP id ob9-20020a17090b390900b001c709bca735mr7626507pjb.151.1649805850184; Tue, 12 Apr 2022 16:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649805850; cv=none; d=google.com; s=arc-20160816; b=WSn7LJhyVfFgeeLBBGlwOQT33iJmSg+/HDISp/sjGF3AlrktQZoLKjdJhskZrLsYZq FnZnldBpEzRpSTl+Awt+GwavGfI6D1pOHmvLDTQoH56uX/W1XzNTYVny85/81dVkY36s 5ayAhpI5uMDYjfTugIVo0w5AOWvrFIphLyU/AenORNzy18IYK/zVWvpPESu7v4/GpIaR yWLYfCklGcJXvHwimqwqWqT1LsiN0JMUhFjoMovJBVsuGWutXHrXSrzal4XSJx7I9uEw xnUeFijxiwItXlPLfPC7o9z5QbWl2fOP7oZf/DFLrfxHGaX6SVvgxgqY9x5QSVsVDelh uy2g== 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=vhpaKAEBJWtEtLUJQ92a1XKM9QjwVj/z4x+eoi5btu4=; b=S6nRnfQjg8yzU7oSs27nzSZhAcaHOBYaXjvdoV0rLelro5GmEpzr3wSwMh1wglFtd0 EV2mpDkoMtuYTc5HZ9yseMpfMpHvdTYLFvTlT0Il6AADnDSA/WvdzAzr4B+5t3+VZPYD 5Xrf6IEGUFSg3Dc3R6S44OVo5JP6VRzxjvNgECsjuD5s7Qwd6Bstk/ztTG8HHxxJuYPf yDKTbAarC/yyPHOSmXBuAJFvzBCKDxsDKXaTIObKLyfhDuyJXbtYe8ttiHgI7CR2ifzi EEND0HgF/N0u7SS/UAjQRu66ke1F6HMEHcbr4+9i6FG5UP0YM0kysCgN8XkK3+Uzx61F UPTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WaktoVgU; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i11-20020a655b8b000000b003816043f09fsi4036018pgr.660.2022.04.12.16.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 16:24:10 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WaktoVgU; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68045EE4D8; Tue, 12 Apr 2022 14:16:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356780AbiDLI4Q (ORCPT + 99 others); Tue, 12 Apr 2022 04:56:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359395AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BED102C133; Tue, 12 Apr 2022 00:22:18 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6F7D3B81B4F; Tue, 12 Apr 2022 07:22:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDF05C385A5; Tue, 12 Apr 2022 07:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748136; bh=uWWbWAFiJjTX83lC6DgCnZBOURJrl4U1pob1qP3NhQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WaktoVgU4crXzxOARhUi+WVok4PMs26nb0sIAPC+RsXIgZ69CKNP/PRU0p/+M7gWb J2seiakeMCn2/J8eLsBdEKukLkHkbuWhYsPvQQ+hsfvbm0N+tNnxbxHyLopyTCnf9Q BHRsqYF2+oAwpg3j/zh/vyo1EsrwCqIPalqDMvAc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Bonzini , "Peter Zijlstra (Intel)" Subject: [PATCH 5.17 333/343] x86,static_call: Fix __static_call_return0 for i386 Date: Tue, 12 Apr 2022 08:32:31 +0200 Message-Id: <20220412063000.930534859@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 1cd5f059d956e6f614ba6666ecdbcf95db05d5f5 upstream. Paolo reported that the instruction sequence that is used to replace: call __static_call_return0 namely: 66 66 48 31 c0 data16 data16 xor %rax,%rax decodes to something else on i386, namely: 66 66 48 data16 dec %ax 31 c0 xor %eax,%eax Which is a nonsensical sequence that happens to have the same outcome. *However* an important distinction is that it consists of 2 instructions which is a problem when the thing needs to be overwriten with a regular call instruction again. As such, replace the instruction with something that decodes the same on both i386 and x86_64. Fixes: 3f2a8fc4b15d ("static_call/x86: Add __static_call_return0()") Reported-by: Paolo Bonzini Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220318204419.GT8939@worktop.programming.kicks-ass.net Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/static_call.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/arch/x86/kernel/static_call.c +++ b/arch/x86/kernel/static_call.c @@ -12,10 +12,9 @@ enum insn_type { }; /* - * data16 data16 xorq %rax, %rax - a single 5 byte instruction that clears %rax - * The REX.W cancels the effect of any data16. + * cs cs cs xorl %eax, %eax - a single 5 byte instruction that clears %[er]ax */ -static const u8 xor5rax[] = { 0x66, 0x66, 0x48, 0x31, 0xc0 }; +static const u8 xor5rax[] = { 0x2e, 0x2e, 0x2e, 0x31, 0xc0 }; static const u8 retinsn[] = { RET_INSN_OPCODE, 0xcc, 0xcc, 0xcc, 0xcc };