Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7355714rwi; Mon, 24 Oct 2022 13:27:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6kDXT9mjyiSp++V5TbUqFr2o+acLmBxwETpzniIGTVgu1e4k3t/b/gXdE+Y99jOdszPBag X-Received: by 2002:a17:907:d22:b0:78e:2788:51ae with SMTP id gn34-20020a1709070d2200b0078e278851aemr28626579ejc.689.1666643242005; Mon, 24 Oct 2022 13:27:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666643241; cv=none; d=google.com; s=arc-20160816; b=IJOUeQegnsEWyBc+iH5qyWhj2Icw49JPNrYcxtaHFKIs9Qc3FgpCW9fCETr7Y2oJdv jZQvm6DWoYxolmyFbb7linOKrZaf1Ds4/yQtz1CGoGtG/MHRvdQZUJKTLq5pMrODbFKS 2z/yFvS2V/zqU2vF9JOseO/8u0mlxa+FUy/2TrXNqSp6NgckjnYDO50i24HPz2+6toZW 9wqR3c5TIA0bAbVL1CdHaKDFjGLhAOzYpZRvTzJCMXQvRiL9bS8EqJYt7yHpVtU7zEOQ Xa12uusNiAdWwKnx6QYJSxnOP3zNyDrYhLekJ8xxqjMmqAYcXBeX97A+IvhTjDpNb/c5 zxPw== 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=1G/QNJDYbtI54uwWC8rzBHh+KSa5Ye+ucDkNqumDiq8=; b=k+1QLdW2m5jiAU4WOkPBx8WMcGFAWugl1s0yiXH7sy18r5WfDtdqMUU172zFu8CaZR jJeqlyH7zKK1ZidpWsJCqAAS2oJc0HQy2uVItiXbuWMZ2zvVM78wATL4MAbt8v1jhfhJ xJKuETx3pDApCW+vYbDqsU/7Uz8QsjckgV7MGJdm23MIlVjsHjbTBTCI1p95zl2F7Hwr vKKrUKw4wuBSUOEbQYoVc+XxMgBiwFwOni2dIT0IBNQ6stOM3a/7VwhIUPEgkw8IWD5Q 1wRCpbZfJRhuz10/bLnZMXRPVgK9ydXsbK9MpIQLdIiXvSEsSSikitC6CbO0O7/tG5ep 69Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nCFTPgKQ; 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 ae8-20020a17090725c800b007813b1924ccsi716150ejc.934.2022.10.24.13.26.57; Mon, 24 Oct 2022 13:27:21 -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=nCFTPgKQ; 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 S231376AbiJXTmt (ORCPT + 99 others); Mon, 24 Oct 2022 15:42:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233504AbiJXTld (ORCPT ); Mon, 24 Oct 2022 15:41:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC4DB157F5D; Mon, 24 Oct 2022 11:11:23 -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 ams.source.kernel.org (Postfix) with ESMTPS id A44DFB811C3; Mon, 24 Oct 2022 11:52:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC97EC433C1; Mon, 24 Oct 2022 11:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612355; bh=pKq6STDJUV1Dof39xPqd3W5VALSdKIfQtmFHciFElP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nCFTPgKQGeLisWi3MP4ZDMRgdadGnvR9sOSwMqMjhxkJPELIgUwDqoJmMlOHaKVH/ dBErm38Fovc6YuRRX7pHaSzbN/jRyl/yPQaY72mj30JZPLLQUP3EjMSIBntTeQW1Oh k1f/4/a/69+cmVcV8WT6dCrQtRFXeUQNMfEatQO4= 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.14 165/210] x86/entry: Work around Clang __bdos() bug Date: Mon, 24 Oct 2022 13:31:22 +0200 Message-Id: <20221024113002.320074738@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@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.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 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 88d084a57b14..3f38541c28d2 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -753,6 +753,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); @@ -762,7 +763,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