From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F21F426290; Thu, 9 Apr 2026 21:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=130.117.225.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775771275; cv=none; b=KKpv06jgdtqUDSN6XhCIAfM6hnAl52gJ/knVjpM1/L5GHd5DjWb43jlsz9b+IdTWUYj2ZHtlrL4sWuALVjapltEOUmw94vTkwJG4BPP1MwQnAu1907X32txSLPIEaAR5+9rC6qCGx4r5zsDEAxjRACi96aUDHx+vnFkbuFQGLZw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775771275; c=relaxed/simple; bh=DOHeJdgg83sZ0T9jmnNAfQfxk9FMb4A2+LrUFf+Vtk0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LnZrnP8bnTZWWhon249oiPeOR1IGEJHlmKEiQjiUhC1oHtkyj38+MTBb3y87b2IxOIGAFI0SKjrIXdjhOUQa3rQg/mX4ptP/p+0zH6aXouh5BPLbcXyILiU6gPGG2vneiQLGrQkXLrRaoS5ogtx7YzAy1+Og82XqSDsYoXOK5to= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=virtuozzo.com; spf=pass smtp.mailfrom=virtuozzo.com; dkim=pass (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b=VdEM7HRy; arc=none smtp.client-ip=130.117.225.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=virtuozzo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="VdEM7HRy" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=18EucyhQlopspBaafNNDLK93kDt938llAL+OtB7xCJg=; b=VdEM7HRyDIjn i7AaD6Rjqx3h0y0Y1GXFTmEUf0ILA8nBL/Wsouoln4qVKeNIUvitEg8LtEgaiONlvbbu3aQXt2VA/ KLUlh5vEfrZ4AxxXsw6qH9wWJld5kDQL4+Z3Q7jlnVq7qaoTPflSSB+tVvv7pcyUuJ4aSsrswRXxx lT1SI1V7T/R2q0+zsuaRW2G+wbqmGDWeZK/EnYylpX6FDaD8RGRePUAPpmCFv8JE5M4CbL2N41yCu ZG7dMrCEZ1NWltlAXDGQXjK4e0AmF26dYY4NOudPSDOHXg1KUm3tI3mfdf5MuE9q+x3/WbpWzl5++ sHvs9kflq03Stf2a7/rEvg==; Received: from [130.117.225.5] (helo=finist-alma9.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1wAxBX-002p6C-26; Thu, 09 Apr 2026 23:47:34 +0200 From: Konstantin Khorenko To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Arnd Bergmann , Peter Oberparleiter , Mikhail Zaslonko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pavel Tikhomirov , Vasileios Almpanis , Konstantin Khorenko Subject: [PATCH v2 1/2] net: fix skb_ext_total_length() BUILD_BUG_ON with CONFIG_GCOV_PROFILE_ALL Date: Fri, 10 Apr 2026 00:47:35 +0300 Message-ID: <20260409214736.2651198-2-khorenko@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260409214736.2651198-1-khorenko@virtuozzo.com> References: <20260402140558.1437002-1-khorenko@virtuozzo.com> <20260409214736.2651198-1-khorenko@virtuozzo.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When CONFIG_GCOV_PROFILE_ALL=y is enabled, the kernel fails to build: In file included from : In function 'skb_extensions_init', inlined from 'skb_init' at net/core/skbuff.c:5214:2: ././include/linux/compiler_types.h:706:45: error: call to '__compiletime_assert_1490' declared with attribute error: BUILD_BUG_ON failed: skb_ext_total_length() > 255 CONFIG_GCOV_PROFILE_ALL adds -fprofile-arcs -ftest-coverage -fno-tree-loop-im to CFLAGS globally. GCC inserts branch profiling counters into the skb_ext_total_length() loop and, combined with -fno-tree-loop-im (which disables loop invariant motion), cannot constant-fold the result. BUILD_BUG_ON requires a compile-time constant and fails. The issue manifests in kernels with 5+ SKB extension types enabled (e.g., after addition of SKB_EXT_CAN, SKB_EXT_PSP). With 4 extensions GCC can still unroll and fold the loop despite GCOV instrumentation; with 5+ it gives up. Mark skb_ext_total_length() with __no_profile to prevent GCOV from inserting counters into this function. Without counters the loop is "clean" and GCC can constant-fold it even with -fno-tree-loop-im active. This allows BUILD_BUG_ON to work correctly while keeping GCOV profiling for the rest of the kernel. This also removes the CONFIG_KCOV_INSTRUMENT_ALL preprocessor guard introduced by d6e5794b06c0. That guard was added as a precaution because KCOV instrumentation was also suspected of inhibiting constant folding. However, KCOV uses -fsanitize-coverage=trace-pc, which inserts lightweight trace callbacks that do not interfere with GCC's constant folding or loop optimization passes. Only GCOV's -fprofile-arcs combined with -fno-tree-loop-im actually prevents the compiler from evaluating the loop at compile time. The guard is therefore unnecessary and can be safely removed. Fixes: 96ea3a1e2d31 ("can: add CAN skb extension infrastructure") Signed-off-by: Konstantin Khorenko Reviewed-by: Thomas Weissschuh --- net/core/skbuff.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 43ee86dcf2ea..59fb4b2bb821 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5142,7 +5142,7 @@ static const u8 skb_ext_type_len[] = { #endif }; -static __always_inline unsigned int skb_ext_total_length(void) +static __always_inline __no_profile unsigned int skb_ext_total_length(void) { unsigned int l = SKB_EXT_CHUNKSIZEOF(struct skb_ext); int i; @@ -5156,9 +5156,7 @@ static __always_inline unsigned int skb_ext_total_length(void) static void skb_extensions_init(void) { BUILD_BUG_ON(SKB_EXT_NUM > 8); -#if !IS_ENABLED(CONFIG_KCOV_INSTRUMENT_ALL) BUILD_BUG_ON(skb_ext_total_length() > 255); -#endif skbuff_ext_cache = kmem_cache_create("skbuff_ext_cache", SKB_EXT_ALIGN_VALUE * skb_ext_total_length(), -- 2.43.5