Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F360CD339A3 for ; Tue, 29 Oct 2024 07:48:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.827072.1241549 (Exim 4.92) (envelope-from ) id 1t5gxe-0004Dk-4O; Tue, 29 Oct 2024 07:48:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 827072.1241549; Tue, 29 Oct 2024 07:48:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t5gxe-0004Dd-1r; Tue, 29 Oct 2024 07:48:18 +0000 Received: by outflank-mailman (input) for mailman id 827072; Tue, 29 Oct 2024 07:48:17 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t5gxd-0004DV-5Z for xen-devel@lists.xenproject.org; Tue, 29 Oct 2024 07:48:17 +0000 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [2a00:1450:4864:20::331]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2809d8cb-95ca-11ef-a0c3-8be0dac302b0; Tue, 29 Oct 2024 08:48:16 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-431548bd1b4so49120055e9.3 for ; Tue, 29 Oct 2024 00:48:16 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b5797c3sm165654605e9.40.2024.10.29.00.48.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Oct 2024 00:48:15 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2809d8cb-95ca-11ef-a0c3-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730188095; x=1730792895; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=qiMKiYdv51H9b+5bAVFCuo4a2BlQNaJkXJKKn8zH6Zk=; b=cI+0C5vkun/u/ResIMvUQRiHuodcSNkY2DGnTIMlZjywSIo1rx+CL6jFzL5eRUri3x qd1+1/Xg5CmMxRsGtWmXSHkoFz+ppxkL6/Qr0uwnK+bjetj9XVgyzmUawDVQ9yAoNjYd 2XHMJqnTba359tyMgyBej97IE2Z1Fr8kT0t3jvg8xA5aw1dDbTDkJpz1VzksOpm34o/r CEdbBFytP+fahLzKdH2jrKyfqhPGr60HsRHYjc7PRJ8l7JyHCnmWkXRDMgpok8oPS1Cs VcQLIHidCTMzWKVgDytmrTlwdUsM4lXEg7ihinlbqK8ep65yd9JCW4aZuEX1QWQ3MAcM Cmnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730188095; x=1730792895; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qiMKiYdv51H9b+5bAVFCuo4a2BlQNaJkXJKKn8zH6Zk=; b=I+4Fh9ippuj6ZOeOWOqzJ8iQJPymtyLW5F/i46ylgDD2Sh/9PaGWgT8xfEvbOO8Jd3 Pfur7Nw0qTJOF9CeBOeQUDTi630aLD/2vxR4B6jwUceNe4m3Eeum3/E29s/lD9ml3DSD zxuhdaEWrfW3GoKvr2y3sCaIlZlpzgovvZj9j1tv3Wktsa4Y6TiiNMrLdA5Vgd3+sNFj VO9+Q7jwHsAqs7GvXov+wiH//IrSapgwWt2Kw5BCJ+/rgsFB3LqR9EfLyaHc4flZ4h49 iAf08pf5xDYHlaPERHdZqAaNWYIna+fSMZ/7EzTIHQgd8mn3OqXys4Z54UHPiYuGwYiE Vkwg== X-Forwarded-Encrypted: i=1; AJvYcCXw+jVy1kTxE09l0nI3/7duKHSMDZ0NrGUAfZj5Vn4/+voxe/5opba18WKlCPxaffIYQhz+vYkdykY=@lists.xenproject.org X-Gm-Message-State: AOJu0YykEWTAU05kSPudEvqghCDbFXoqRRb0iMoQO4K63WzAN681R9Ox e/zVBefUDeYNvYrqxYJKxPSbY/xXC1JsMQZg4PbJVyXO2QUZelGpTMMmbl3utsHDPLTLFCYyaHE = X-Google-Smtp-Source: AGHT+IHIhKGkhQLzzJ85hnL8dRsOnWvB2ivKQnY5iXLdmMUUh5MUAVXxFeGhUvaxTDg+81PxilFqQA== X-Received: by 2002:a05:600c:3550:b0:431:4a5a:f09a with SMTP id 5b1f17b1804b1-4319ad16150mr91220465e9.24.1730188095495; Tue, 29 Oct 2024 00:48:15 -0700 (PDT) Message-ID: Date: Tue, 29 Oct 2024 08:48:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 02/10] x86/ucode: Delete the microcode_init() initcall To: Andrew Cooper Cc: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , "Daniel P . Smith" , Xen-devel References: <20241028091856.2151603-1-andrew.cooper3@citrix.com> <20241028091856.2151603-3-andrew.cooper3@citrix.com> <99ba9bcf-f356-416a-b355-f32e622d1406@suse.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPx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GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 28.10.2024 18:12, Andrew Cooper wrote: > On 28/10/2024 1:38 pm, Jan Beulich wrote: >> On 28.10.2024 10:18, Andrew Cooper wrote: >>> The comment highlights just how bogus this really is. Being an initcall, the >>> boot allocator is long gone, and bootstrap_unmap() is a no-op. >> How's the boot allocator coming into the picture here? This is all about >> (un)mapping, not allocating. >> >>> The fact there is nothing to do should be a giant red flag about the validity >>> of the mappings "being freed". Indeed, they both constitute use-after-frees. >> I can't spot any use-after-free; the pointers in question ... >> >>> --- a/xen/arch/x86/cpu/microcode/core.c >>> +++ b/xen/arch/x86/cpu/microcode/core.c >>> @@ -758,28 +758,6 @@ int microcode_update(XEN_GUEST_HANDLE(const_void) buf, >>> return continue_hypercall_on_cpu(0, microcode_update_helper, buffer); >>> } >>> >>> -static int __init cf_check microcode_init(void) >>> -{ >>> - /* >>> - * At this point, all CPUs should have updated their microcode >>> - * via the early_microcode_* paths so free the microcode blob. >>> - */ >>> - if ( ucode_blob.size ) >>> - { >>> - bootstrap_unmap(); >>> - ucode_blob.size = 0; >>> - ucode_blob.data = NULL; >>> - } >>> - else if ( ucode_mod.mod_end ) >>> - { >>> - bootstrap_unmap(); >>> - ucode_mod.mod_end = 0; >>> - } >>> - >>> - return 0; >>> -} >>> -__initcall(microcode_init); >> ... aren't used anywhere. bootstrap_unmap() is "just in case" (perhaps indeed >> a no-op at least nowadays), and the rest is field clobbering. I'm okay with the >> code change, so >> Acked-by: Jan Beulich >> yet I'd like to ask for the description to be "softened" some. > > As I said, this could be folded into patch 9, given this particular > arrangement of the series. I certainly don't mind the folding, but then I'd still like to see the description of the resulting patch before giving a (hopefully) unconditional ack. > The UAFs are apparent *because* the comment demonstrates a false line of > reasoning. > > ucode_mod literally is used after free.  ucode=$n is genuinely buggy > today, because its a stash of a physical pointer across move_xen(). Maybe my problem is that the UAF is elsewhere, not in the code you delete? If so, it might help to simply point out where the actual bad use is. As it stands, microcode_init() doesn't have any uses (reads), only writes. What I agree with is that the comment there is at best misleading. Jan > ucode_blob stashes a virtual pointer.  This was even noticed in > dc380df12acf ("x86/ucode: load microcode earlier on boot CPU") > > --- > It needs to rescan the modules in order to find the new virtual address > of the ucode blob because it changes during the boot process, e.g. > from 0x00000000010802fc to 0xffff83204dac52fc. > --- > > which highlighted the problem but duct-taped over it. > > ~Andrew