From patchwork Mon Oct 24 11:31:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8849 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp432931wru; Mon, 24 Oct 2022 05:48:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7V6IQJJvv2HOxxJ1ckjFmXVEGT2bmdnU+GVN5wsUbtIVMC6+AnHqDMaOxOmG6uWbIP8cxV X-Received: by 2002:a17:90b:1bc3:b0:20d:75b8:ee74 with SMTP id oa3-20020a17090b1bc300b0020d75b8ee74mr75946638pjb.1.1666615686285; Mon, 24 Oct 2022 05:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615686; cv=none; d=google.com; s=arc-20160816; b=AkS4OqL82RUnotHW6ttEAbICiAoaGBBREl6CW5atqymUYYLb9pOCdQF2l1WxArdz69 vp5/LHDUVpBs0R7TTJW0oAp6hqQ4iM2xtn+xUw9U8EMAReELu5nSs/pNp/SAqGIODekA GQ4pdHxDjUzBN17xV3jLKb/pI/7RogzCbwXHdNQehNA1jQt/HqqzXxP3oGVq4zCwoYPJ PKjRV0gm348aGWxXT2Cya4SFDbLe9G7kiw5CJnrMRwH63gcKHsrDjVkxi0wR4b/BOOVh hGtUbRVr5bDBeUWhV3DRgxOm72aJ6o9NOcWTjvNCGwH8Hm2EG6ijZ6J3d3sCmt56/EuU Xq3g== 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=Vu6DnC/P6o7/3l0/q2sbN/O7vaXsYXzI6YUf1WOVMdE=; b=VmmTG841pt8guOz7q3ZgAt2vMxdetlfxd5x8rj3ES4wAnP5YjvPqc/s8c/VfDfUcrd 4gUysM0YPrKrF4nr+o/raKm1E00Mod+cYSjDYsZAdTnGVnB6ajefRmrMSoezScLELGS2 RSgKo4Ja64kGa8Sk5o4YA9XpR0UoJxJChvtX79Lfr5mr9VHAqouRXDnr0FWAY8mFv8io L9pUYX+hCTHXKWLl0jdO/XrIYCBTwk82UKe182OK3k9nsjJpVM4pS0pTMOdpVaUNAroO K2BQyAHGRUBnGDyoVz8RBzwL7ze8lZpN2OX7NrCzu5fyQUZnJ4mUFJP3GddeidiTNc+D 7Ndw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pND0li9P; 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 206-20020a6306d7000000b00460dd0eed0csi36834390pgg.176.2022.10.24.05.47.51; Mon, 24 Oct 2022 05:48:06 -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=pND0li9P; 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 S231449AbiJXMip (ORCPT + 99 others); Mon, 24 Oct 2022 08:38:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233808AbiJXM26 (ORCPT ); Mon, 24 Oct 2022 08:28:58 -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 5176F87689; Mon, 24 Oct 2022 05:02:39 -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 7A538612CC; Mon, 24 Oct 2022 12:02:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64D13C433D6; Mon, 24 Oct 2022 12:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612932; bh=HDBZX01FN2W9c75Sd8NoXHb1ZhN7yyXXynCHY/64+/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pND0li9PULhAZ5WGWsVwxg82gs5hly/Vnn/CKFpKa2LRY7bOsjDtEpcmCVbQwj/O2 gn1YSu/K3jWSnXc47NgdgmPwB9t620DY8KGXQCWZFjktH23fUfjmrYlggGyGdSzy1g 5UskNI2UYgsHLyuQGVhQKGGGC6UFXCP8xlpcR/RA= 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 4.19 174/229] x86/entry: Work around Clang __bdos() bug Date: Mon, 24 Oct 2022 13:31:33 +0200 Message-Id: <20221024113004.718917343@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747573209826523086?= X-GMAIL-MSGID: =?utf-8?q?1747573209826523086?= 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 8f1ff8dad2ce..04bfd9c3987b 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -752,6 +752,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); @@ -761,7 +762,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))