From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E3A5C77B7A for ; Thu, 1 Jun 2023 17:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hIuCa3fWij7ADkjEh9ybX9rkmUo1eeH94a+mJfasYmM=; b=xgWJo8VsuVJ4Nx ie6Z6Mc/sN+TqWS6hNUtrtKnt98MMElh7WYczqLK72TKgtIHyuE5vlpQ1AqsVtV9MXh5UuUG9XgBl vWJr8+iAL7OP5tzEQwbeQeDN1s5cEig8JMr5bigvVmIp0js3ScQR+fedrHHZJAbEpO7D9lJqVAGDy 1XQQx0u79mOCiAEy4TG+Z4l55fSp+NPS6GXKunvkafQvbryOn2h+a9KTr2J5SUcKi5MBGJpz80g6w 8PXuDqm2ncEMilmRJmlTlAzMUdB3VMWQ7/wvimVDnx9diDESIHzBhC2BAIm8hc2uRb9lRinwRWVJ3 xcYvAYODHB5jJrdBaBPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4lto-004Nw0-0v; Thu, 01 Jun 2023 17:15:44 +0000 Received: from mail-pl1-f178.google.com ([209.85.214.178]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4kwy-004Bnl-2y for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2023 16:14:58 +0000 Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1b0218c979cso5896755ad.3 for ; Thu, 01 Jun 2023 09:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685636094; x=1688228094; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hf1MMDnk8ATuiHQnpftM3deH6vV2jBlcAPqcuKGi0Ek=; b=BLOJsskDJTv8yn+ZTSU8DPbhPH9VAEpQcNphr4RmScmbAmgWrp0GukfjFro2r265wS 6nmFRGSXXGa7RcbInQP2zovN07D4+fErz4lNsHF1JQiB5r265YWCLnVrXvfV9fIuuPKD bp9H8NF/OqTzmF7dGtp2dpe9nzNFgZX5Yid94= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685636094; x=1688228094; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hf1MMDnk8ATuiHQnpftM3deH6vV2jBlcAPqcuKGi0Ek=; b=DqpqDYuItU+/89jyYXa4FbyJpSHOObk7FJkgFTvo00E7ybVDJ+j88DCjQEJLALB/uc 4tuAG+a7iDe+LmbGS2vmzuCbc5R8Jqj0t6xbzss9Kj8H7BDvxaMyksEUzpAFS+n4CJVd +1mLIIdk9Gonds2KrhByAw5Chy5tYD9syhdTJstOh0/WSIGX+bMVpAsmZcdhuzlW3rfh IvVKYk/8zWp5KA1BvEoWZrSnGKnpHhEKGLnKX2VpPDXgOe+mrxQSBBm11L7KtkUNV2Mr yWch7DpbhFgruqnM65FWrZ2G5D7Fi75XJfB18vJAe3aMePXs2FB8eL2kiST0HCpIgyNT /1pw== X-Gm-Message-State: AC+VfDx6uEqjp6Nt2w5+7kjlP76rL0MyLFjrzj9lxiirTdbcqabac/6R mSiSZid2DiouCA+Bf6/tJGE51A== X-Google-Smtp-Source: ACHHUZ6ljnrlP3/ilIjQD+BaM7rS5m1dEr3AyuNBWAGikj0kydZDXi/vDU4GxazSWUNgX9O+Y6PY3A== X-Received: by 2002:a17:902:c20d:b0:1ac:6d4c:c24b with SMTP id 13-20020a170902c20d00b001ac6d4cc24bmr6045835pll.3.1685636094447; Thu, 01 Jun 2023 09:14:54 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id g14-20020a1709029f8e00b001b176ba9f17sm3680035plq.149.2023.06.01.09.14.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 09:14:53 -0700 (PDT) Date: Thu, 1 Jun 2023 09:14:53 -0700 From: Kees Cook To: Arnd Bergmann Cc: kasan-dev@googlegroups.com, ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com, dvyukov@google.com, vincenzo.frascino@arm.com, elver@google.com, linux-media@vger.kernel.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, ardb@kernel.org, mchehab@kernel.org, Arnd Bergmann , Dan Carpenter , Matthias Brugger , AngeloGioacchino Del Regno , Nathan Chancellor , Nick Desaulniers , Tom Rix , Josh Poimboeuf , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, llvm@lists.linux.dev Subject: Re: [PATCH] [RFC] ubsan: disallow bounds checking with gcov on broken gcc Message-ID: <202306010909.89C4BED@keescook> References: <20230601151832.3632525-1-arnd@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230601151832.3632525-1-arnd@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230601_091456_978468_B0CAE123 X-CRM114-Status: GOOD ( 25.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jun 01, 2023 at 05:18:11PM +0200, Arnd Bergmann wrote: > From: Arnd Bergmann > > Combining UBSAN and GCOV in randconfig builds results in a number of > stack frame size warnings, such as: > > crypto/twofish_common.c:683:1: error: the frame size of 2040 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] > drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c:1589:1: error: the frame size of 1696 bytes is larger than 1400 bytes [-Werror=frame-larger-than=] > drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c:754:1: error: the frame size of 1260 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] > drivers/staging/media/ipu3/ipu3-css-params.c:1206:1: error: the frame size of 1080 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] > drivers/staging/media/rkvdec/rkvdec-vp9.c:1042:1: error: the frame size of 2176 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] > drivers/staging/media/rkvdec/rkvdec-vp9.c:995:1: error: the frame size of 1656 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] > > I managed to track this down to the -fsanitize=bounds option clashing > with the -fprofile-arcs option, which leads a lot of spilled temporary > variables in generated instrumentation code. > > Hopefully this can be addressed in future gcc releases the same way > that clang handles the combination, but for existing compiler releases, > it seems best to disable one of the two flags. This can be done either > globally by just not passing both at the same time, or locally using > the no_sanitize or no_instrument_function attributes in the affected > functions. > > Try the simplest approach here, and turn off -fsanitize=bounds on > gcc when GCOV is enabled, leaving the rest of UBSAN working. Doing > this globally also helps avoid inefficient code from the same > problem that did not push the build over the warning limit. > > Reported-by: Dan Carpenter > Link: https://lore.kernel.org/stable/6b1a0ee6-c78b-4873-bfd5-89798fce9899@kili.mountain/ > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110074 > Link: https://godbolt.org/z/zvf7YqK5K > Signed-off-by: Arnd Bergmann I think more production systems will have CONFIG_UBSAN_BOUNDS enabled (e.g. Ubuntu has had it enabled for more than a year now) than GCOV, so I'd prefer we maintain all*config coverage for the more commonly used config. > --- > lib/Kconfig.ubsan | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/lib/Kconfig.ubsan b/lib/Kconfig.ubsan > index f7cbbad2bb2f4..8f71ff8f27576 100644 > --- a/lib/Kconfig.ubsan > +++ b/lib/Kconfig.ubsan > @@ -29,6 +29,8 @@ config UBSAN_TRAP > > config CC_HAS_UBSAN_BOUNDS_STRICT > def_bool $(cc-option,-fsanitize=bounds-strict) > + # work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110074 > + depends on GCC_VERSION > 140000 || !GCOV_PROFILE_ALL > help > The -fsanitize=bounds-strict option is only available on GCC, > but uses the more strict handling of arrays that includes knowledge Alternatively, how about falling back to -fsanitize=bounds instead, as that (which has less coverage) wasn't triggering the stack frame warnings? i.e. fall back through these: -fsanitize=array-bounds (Clang) -fsanitize=bounds-strict (!GCOV || bug fixed in GCC) -fsanitize=bounds -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel