Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp314607qtb; Wed, 19 Oct 2022 02:39:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5dOE1GBk+7GS0K9eDiJZ5RmLy+eFhtzGLtlxWKz0woYN1p56IHh6j+eTqi18wH8hViuWPL X-Received: by 2002:a05:6402:5114:b0:45d:b850:a4e2 with SMTP id m20-20020a056402511400b0045db850a4e2mr6462714edd.316.1666172375779; Wed, 19 Oct 2022 02:39:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666172375; cv=none; d=google.com; s=arc-20160816; b=jAUAFDpKrn7maYBHn3kBSWxUPiiops54pnGTYfJFPH2LExAGzZWxHyNDGoyeiHqUDF JJHM3eghVmYoiPVzyrrIcsAS8cX80kxOnpbfSCiNdu81XnUIPNWp3+itNMt2gzzYab5F 0SFbBaOiDH1hz5aCW3ohvRIuPYEBWM4qjUy9iqLNHZGofsT2wcs68D/Mq6xA7MuwkReJ qVuMhTgwGnucyYc3yyFASXxqo8oILiaAttcQtdpHAbP4RXCVzgxkyU67P/lkbzut9Dv+ lENRoqP+pmdlRcENx+dNE6SUzh7FMQCwI4yHFwuTicpy0tzb+71+pkXL7gy5x6wcYEdj 5SOw== 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=vuA9a6t3fOnapTOTnGUH/1TrbgIT7put1zz010HiY+U=; b=DEDwMlk1UTtMcSaErbwf4vvfjR931wSrXnXzRluPSOh+5hcfT8B0WsgZnj0HQf7FB/ bb4LgGY4bJn1gf1JiIy9BC0cnNRCjQ2OG+xiYq4G+24AFkRjkm5fKFZgCh6S8RVEnaZn 1t2dWcQytqwA4sIaXt+QuJ3xWAe9OUg++sImojL9K1SYF2Z/wm1DMbD//VXO4P5tcwml wuBVBnanpabYHDF9gjqEanfrmKFpT5T1QeKNbow0p63HXNhOL3Rz9HHJBeWFVoY3RVCf y6G3oA89PLbXEOMCTy/G7WJ15FcOLhYOBSxMsX5oKhvfBN9nVueZsPrFKu1/0qQ9Xp+H 7uPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FKrkq4mx; 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 gb22-20020a170907961600b00734b2821879si15382674ejc.898.2022.10.19.02.39.09; Wed, 19 Oct 2022 02:39:35 -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=FKrkq4mx; 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 S233349AbiJSJ1x (ORCPT + 99 others); Wed, 19 Oct 2022 05:27:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233565AbiJSJ0d (ORCPT ); Wed, 19 Oct 2022 05:26:33 -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 D02EBE52F8; Wed, 19 Oct 2022 02:11:55 -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 5E86261831; Wed, 19 Oct 2022 09:09:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49A47C433D7; Wed, 19 Oct 2022 09:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170579; bh=WOtLqPtfTzhG6xYKuXLzf9SXFlrNx350kTurMW1iEWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FKrkq4mxl7UzWAyUXth0fYW43x5dhgids6rAsLpKKl9ExuG+YJ4gAIe3baLB+TKdo MGfLJ1/67Ht6N1AARsFqPu0sLeL3Vbzpd4C1gmpx5Fp/LPj0oJIBqdBPVugqUUP/LH gPNcImneQBiLWeW697ON9gShNI+BBoJCeoxOyoa4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , xen-devel@lists.xenproject.org, Kees Cook , Sasha Levin Subject: [PATCH 6.0 676/862] x86/entry: Work around Clang __bdos() bug Date: Wed, 19 Oct 2022 10:32:43 +0200 Message-Id: <20221019083319.836953318@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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: Kees Cook [ Upstream commit 3e1730842f142add55dc658929221521a9ea62b6 ] Clang produces a false positive when building with CONFIG_FORTIFY_SOURCE=y and CONFIG_UBSAN_BOUNDS=y when operating on an array with a dynamic offset. Work around this by using a direct assignment of an empty instance. Avoids this warning: ../include/linux/fortify-string.h:309:4: warning: call to __write_overflow_field declared with 'warn ing' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wat tribute-warning] __write_overflow_field(p_size_field, size); ^ which was isolated to the memset() call in xen_load_idt(). Note that this looks very much like another bug that was worked around: https://github.com/ClangBuiltLinux/linux/issues/1592 Cc: Juergen Gross Cc: Boris Ostrovsky Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: x86@kernel.org Cc: "H. Peter Anvin" Cc: xen-devel@lists.xenproject.org Reviewed-by: Boris Ostrovsky Link: https://lore.kernel.org/lkml/41527d69-e8ab-3f86-ff37-6b298c01d5bc@oracle.com Signed-off-by: Kees Cook Signed-off-by: Sasha Levin --- arch/x86/xen/enlighten_pv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 0ed2e487a693..9b1a58dda935 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -765,6 +765,7 @@ static void xen_load_idt(const struct desc_ptr *desc) { static DEFINE_SPINLOCK(lock); static struct trap_info traps[257]; + static const struct trap_info zero = { }; unsigned out; trace_xen_cpu_load_idt(desc); @@ -774,7 +775,7 @@ static void xen_load_idt(const struct desc_ptr *desc) memcpy(this_cpu_ptr(&idt_desc), desc, sizeof(idt_desc)); out = xen_convert_trap_info(desc, traps, false); - memset(&traps[out], 0, sizeof(traps[0])); + traps[out] = zero; xen_mc_flush(); if (HYPERVISOR_set_trap_table(traps)) -- 2.35.1