Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp832199pxb; Tue, 12 Apr 2022 14:43:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT2BZDcbvUymdo7vPFg4nznN491tpb9dmmwPyIOODKRlumV6HJcUG4a/2OF3yYAcZWlgAm X-Received: by 2002:a17:90b:1d90:b0:1ca:9f55:3b78 with SMTP id pf16-20020a17090b1d9000b001ca9f553b78mr7234062pjb.38.1649799799097; Tue, 12 Apr 2022 14:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649799799; cv=none; d=google.com; s=arc-20160816; b=QkVAjpx3fDkC0SJDBE/oYkv1wqFiY/l9192cMWS7PHchjTyKd9HIOqT33c6nwkmgnF 5CvArO9Ccn0PbKsdz1uy/crcObaG6Ip2jEY+76lz+pqDyyBQLLo86ogiBtdB+NgN3kcG VyY3EufcBMrS9k2Ja7X5m9Xu4C0vCd0CdEQx+WSK6lEU4PbxwaT079/xgsYn0ufWh6JY FWZC7boP3JttUFl/eqxfDa0PrlsZ+luE5HkwKn06fiMWEzKfqGHM8CYw4MnyePxszzam afivY5oyZgDcc9t6hVLC0/vnUq+Yqr8VndtisftKb0uQ7E/d7g4WM4xTuBYedByXIP0d U1Dw== 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=OGcu8dFfJs2TQ8HcRLm4QRSUAtO1wbQVeAhj/mkcsT0=; b=JVvk6mUlbYKP51rp8CBd7cjM+i0D0yjPB7VvuhqRSkga7wm7ptB96zAf5YozEu5Reu W6zAJjDoexkagXUimkpQeLEEn/9zCqdGpLeVWkvwMXQw6JTaY/T8fMh/GakZuFqmfI9V bb3RsemjGRhDBHfq28fasE98TH1wyjy5JWjcD8w9hdthX6/sj4RivEKmVDkbha/mpNLS fJnLjKA2ZWF9tP+L/moall4fNYPcYgLuXfhZlhzcTPUEv1gaHxe70etHM9JRwAineurW jLlasxNhpUVcECDZip8/0fdwMqyCtBlEa1TCZHRM5k+yqL8KoFe0QE8YhU6Ig1hqOnrq vOWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F43f+qRB; 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 31-20020a630e5f000000b003986444128fsi3731619pgo.671.2022.04.12.14.43.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:43:19 -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=F43f+qRB; 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 B79F11336A7; Tue, 12 Apr 2022 13:44:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357984AbiDLITQ (ORCPT + 99 others); Tue, 12 Apr 2022 04:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354857AbiDLH0y (ORCPT ); Tue, 12 Apr 2022 03:26:54 -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 391FA47384; Tue, 12 Apr 2022 00:06:47 -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 B9DDD6146F; Tue, 12 Apr 2022 07:06:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC1EFC385A6; Tue, 12 Apr 2022 07:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747206; bh=9VK7Q9d8kUXkXOYxC5DYC7ucjglVOtJGawK4c7nKiDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F43f+qRBYxl7s2JwFmOszL1eurK6nXct+5AkDg/zY5ZJIhvXv3Ier9mF0JbPUCVgP f0TALr1TTQHxsUMkYkmbPLOGMAhX2PURKgfab1FUv46i32rS4C4V/P7nGJretUD/Eu BL5zAp1c3Fog8TSYv5BZHzyARGstukvbp8swSRjc= 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.16 280/285] x86,static_call: Fix __static_call_return0 for i386 Date: Tue, 12 Apr 2022 08:32:17 +0200 Message-Id: <20220412062951.734171923@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062943.670770901@linuxfoundation.org> References: <20220412062943.670770901@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 void __ref __static_call_transform(void *insn, enum insn_type type, void *func) {