From nobody Sun Nov 24 13:21:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1722864418; cv=none; d=zohomail.com; s=zohoarc; b=iuFjcVsBMlxNDaeb1XzQn5K4Ebi3JCT9U/mLerLPeWCJn+YDuoL6jN9XPY1IReiKWc7R/abzeukpqY1RT8Ynjb7c3GSgP0B/XVtIyOVgA2St1+FDoNMuoR3Yj8Q5YZIgvaf72U506sy7XR32/3RMJOA7PTvQsNvzNgyqzgLgtTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722864418; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+LzdTN0LrxG38E8N8sPxyACXjQToDaja2vpqjapp9Eg=; b=KCvKC06Mer+4Xm/9D21Z2SoZGxRjkNlwfnI6a4DIwfY+PpvqTZGPqI7KQPGMoqGIn5z47Udp5UUyXmnSADihoYWkr6IRaYFxzLJvj4YL8/4QV8ThGBwp/VchxDy3DKGf3D/JsgOEPnNj1lvzZU3iZyU1C3nNcPtQSnLSE+nWi1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1722864418753195.48050504741616; Mon, 5 Aug 2024 06:26:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.772169.1182599 (Exim 4.92) (envelope-from ) id 1saxjJ-0008FO-83; Mon, 05 Aug 2024 13:26:29 +0000 Received: by outflank-mailman (output) from mailman id 772169.1182599; Mon, 05 Aug 2024 13:26:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1saxjJ-0008FH-5D; Mon, 05 Aug 2024 13:26:29 +0000 Received: by outflank-mailman (input) for mailman id 772169; Mon, 05 Aug 2024 13:26:28 +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 1saxjH-0008FB-Vu for xen-devel@lists.xenproject.org; Mon, 05 Aug 2024 13:26:27 +0000 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [2a00:1450:4864:20::62b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5123bfbd-532e-11ef-bc03-fd08da9f4363; Mon, 05 Aug 2024 15:26:26 +0200 (CEST) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a7a843bef98so1058042766b.2 for ; Mon, 05 Aug 2024 06:26:26 -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 a640c23a62f3a-a7dc9ec7311sm450930166b.195.2024.08.05.06.26.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 06:26:25 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 5123bfbd-532e-11ef-bc03-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1722864386; x=1723469186; darn=lists.xenproject.org; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=+LzdTN0LrxG38E8N8sPxyACXjQToDaja2vpqjapp9Eg=; b=RdJmJdVBRZeoxP0pmdm9ihdh4hHZINOR2KgzvUyeDCzabyD+jqwaB7EIUntFWBdwcF S3d4L7/RIdGhc9jGrKypiIDcQ1lXeSah1T4KpLU/9cPwGeXuI6HRGWE4ql6oqHNaiXf1 zK5C5uTNLoDGeSrmcjOmc5O7x05svH2io65P6OvTbpitgMbEVpG6pG0TzHZ95/5/R2rO 2U1o5A4AzPUO/N29qP/Th1k6x16q0sfERkkui5wJljTQs6amEV42FNSX2QUJ0pLG3kJd 2GRnzb0MQBgqagLTUFvFkcjp8wHfhMDZMLrjJlfF4sRlfuYsdacp2f6pDyskKpj7EV5+ 9a1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722864386; x=1723469186; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+LzdTN0LrxG38E8N8sPxyACXjQToDaja2vpqjapp9Eg=; b=Vy5xd7B5OdV0IKVaA8Tie0/Z0RGCOf86rrvUz6QXZdJ3tcPjBpVZfiiYigPtSgQLpE tAZ6kqkX0q1IqQEnqsJkXEEAcUsgf/cadFNYBjcSfpeFgWGYm/CS4f2Ozfcok4ME8h4Z NSa+0dKMYMlmGQQhnEbnShGvLGqSn1kmu6Ui2k2aL8ThM2wBCLEHADH0bQdkejOqOsin p3Pzkmy46Y2kUj+rz90kye39O6KNOSDdvVq0f14loBUrcf4Y43/1eFTEaHOHkr4K/xoZ 1bzoTKfEwzh/WLmPjZmlAk5zLMv4vrRS9GScY7ZDLXEbcP3ctdsNz2xeBF1EVhb0TD5Q opZw== X-Gm-Message-State: AOJu0YyjY1ixAVYt1qdBig0deGJ6b1NRlR/WV31TCq9YClh7UR6Q1bQF vWgSj6me8zKp+b+QUtJwbOCQe1GbaUV/I9rFCmm+NYKAlH8LLDY9ALiUVZXmgVE0yXvobs6O+ho = X-Google-Smtp-Source: AGHT+IEaSEApBX9iP9WPNnL2z7ZkuNTBn/gY4lvs+wzc4dIaNoeI7NG7bGtwnguukxMUlhzFhUkQYg== X-Received: by 2002:a17:907:2d08:b0:a7a:929f:c0ce with SMTP id a640c23a62f3a-a7dc4df9533mr670154366b.19.1722864386087; Mon, 05 Aug 2024 06:26:26 -0700 (PDT) Message-ID: <81ae365f-98b4-4bb6-bbb6-c5423dfda038@suse.com> Date: Mon, 5 Aug 2024 15:26:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= From: Jan Beulich Subject: [PATCH] x86emul: don't call ->read_segment() with x86_seg_none Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAU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ui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1722864420769116600 Content-Type: text/plain; charset="utf-8" LAR, LSL, VERR, and VERW emulation involve calling protmode_load_seg() with x86_seg_none. The fuzzer's read_segment() hook function has an assertion which triggers in this case. Calling the hook function, however, makes little sense for those insns, as there's no data to retrieve. Instead zero-filling the output structure is what properly corresponds to those insns being invoked with a NUL selector. Fixes: 06a3b8cd7ad2 ("x86emul: support LAR/LSL/VERR/VERW") Oss-fuzz: 70918 Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- It is pure guesswork that one of those insns did trigger the assertion. The report from oss-fuzz sadly lacks details on the insn under emulation. I'm further surprised that AFL never found this. --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -839,7 +839,8 @@ protmode_load_seg( case x86_seg_tr: goto raise_exn; } - if ( !_amd_like(cp) || vcpu_has_nscb() || !ops->read_segment || + if ( seg =3D=3D x86_seg_none || !_amd_like(cp) || vcpu_has_nscb() = || + !ops->read_segment || ops->read_segment(seg, sreg, ctxt) !=3D X86EMUL_OKAY ) memset(sreg, 0, sizeof(*sreg)); else