From patchwork Mon Oct 24 11:31:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8971 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp437867wru; Mon, 24 Oct 2022 06:00:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7fzCLr7Prv63Ade0Il84AjGpCJAeBWNnE8+4eeXtOMkcDSYzB0SqcqyT5t/KBtXi9WAPuk X-Received: by 2002:a17:902:e5c1:b0:186:897f:b8ee with SMTP id u1-20020a170902e5c100b00186897fb8eemr12447486plf.151.1666616435040; Mon, 24 Oct 2022 06:00:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616435; cv=none; d=google.com; s=arc-20160816; b=gLK/O2kV/LIezgbfNLbyM4l96y4IyQDLxe5slVfRasI3XYlbl9LJROiMLpBS1hSnjh bYwThMPQwk6f6xM7lURfg5+HZddPdqBtV5HDvZs7sAdI94iVjLiBzRfeupGptim+R+sw tfBe8pdTCUM9tPUl+V9f8tyywLrH3oq7x8UUo3VwMK2YJHxJnJNYzy8XQtRvkcvFJESP yKUCeieB3WSTBWQ5FiD4p+OPW5g5UC6Al6oryhmDF2gzeSjPdZRGbNpToov+f8JFcQzw 2F4VcYoMKk+AwqrpE0rBnuh88W+hRSDPCQLPlf4nYj7QyY1TUtw9lHzTfTQfnwcrnrYP zajw== 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=TG3FRj7yyWrVV+iuTPWGFwVcQ/wa5lJcYj0DH4TL21I=; b=dZuFTBDR410qBGwA8c2Oa52O/ztIFxUANduCQKcupyT9keyns2Vhp06007yI1EaWNl gt5YEaPKY41qt8eMXaOs0sgaM3LEhhnFnAIT7GgL4XU+/gL7/oDoAlYnKE5+KRzRpInD NZJn82Qz5tcHed6pT2BDSlMT83Vi7WTjO/VBGPHMeGy6eaQKPOLAMEorv8Nf0Z4Ywv91 nB4iaAvXmS9nAo0bEfhL3fzoTfVf1HYlzD77WlX6Hj/lTbZpCD3KaK4/CdWKsn13c+AH IT9TwzRvnedj8E043B9hji1cY3MY5RAKMKVLyLSV8iTwBPmb4JC1eozbV0MgfM/2PtBL Ox4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N3lJStRM; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a655901000000b0042ad0333df1si37128790pgu.479.2022.10.24.06.00.16; Mon, 24 Oct 2022 06:00: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=N3lJStRM; 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 S234845AbiJXM6f (ORCPT + 99 others); Mon, 24 Oct 2022 08:58:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234755AbiJXM5m (ORCPT ); Mon, 24 Oct 2022 08:57:42 -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 E9A8B97EE9; Mon, 24 Oct 2022 05:17:12 -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 D203861320; Mon, 24 Oct 2022 12:14:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B814EC433D6; Mon, 24 Oct 2022 12:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613648; bh=q35u9k51iKg4WFnPv2+Jft9j9x8EK3aRtf5Pa+iGBKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N3lJStRMIfM1xWFYqREc3zv03PcsQNTZREFDYQk+pT9yVx9WozZGOrOlVilhzF22/ Wr5AjCofsHKgneEeFUqozvy/Km3bGtfIXKZH2yz+iNPksyqfK+Wqd9juu4GNyC7bVk kuLnDNBQIeOKtz3FztqY9EbZUVna89qVxZT0rJbA= 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 5.4 189/255] x86/entry: Work around Clang __bdos() bug Date: Mon, 24 Oct 2022 13:31:39 +0200 Message-Id: <20221024113009.238496303@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747573994847897107?= X-GMAIL-MSGID: =?utf-8?q?1747573994847897107?= 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 65cf405cd975..26b35e75b701 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -759,6 +759,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); @@ -768,7 +769,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))