Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp211692lqt; Mon, 18 Mar 2024 06:04:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBHOuLBbrKqRtWykePBkDmIF7NSknB0A3R1DGu2rBXDgAeCCfJ1IaKvK7Z2p+OhAhAf1UKYbyGCFaoN2UlJVV0vqF1Fxi/VsQOjvHuCA== X-Google-Smtp-Source: AGHT+IGS+m7WHpDMoR0jXRgrLyE92D+kcHPTKD2ce83cEFZuftY6QuHkSIWxAB0aNABMDmdNOv+v X-Received: by 2002:a92:90f:0:b0:366:af78:69db with SMTP id y15-20020a92090f000000b00366af7869dbmr5535375ilg.30.1710767085689; Mon, 18 Mar 2024 06:04:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710767085; cv=pass; d=google.com; s=arc-20160816; b=BjeISjS5rfp/qOv+VUBmoMp1BBnSRVwq/AX0qg6NaSZP8Ha8rn88l5IZUbtxdFCLy/ gAd20tPA65u+7cMdqLMLOs4EIJnlryeEZEG8TARJP16ltlyU/+DJn9VVIaNrknWlfCWh FXbrnNT1nL/PQ+iendfbkov6BBtSeismsic9MarS4d3QyNxYTXjgwBM8zKZszfGKBXbx /a4mNh+RqY1ZaYS/7JEx3ikhwwm4LDws2ZgUsckAHlmqzFmbsjmk527OmjpvpcAzStMJ ioCJRSgRO6sBHpAE8mSkQPxuEZ4noqcx2AGBaJO8AT7lmEXocQhgNAIkRV3n0lIIxDK2 1Qqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vlE6F/lspz6vXu97uG7Tl6o6pdMcfq3nhp77YHZkE3Y=; fh=iaMc8qbrcAb26pJlr23GcSFusd+aGkvIHrXDh3azOIE=; b=CMxOUKGYlAn3UDz4W1tO082T2nA3ivAZI6kK8lLt0gB3LZIZTWpRJbVUDDhaKlW+Nz qJvkTcMOZjnUAO8INQNEzEMmqRcFyr23mYsNSemf9f3VMrTKzI2QoJPrb+5ns5ZmWTx/ zfXBPk54GU5wvQmKLu9PWILxmpbfGXcCHr9AI9uV+mrmjujpIEX1IW5UURpQFEfvTXA8 MACG4xiRxYrsWQ/G6OjtCIgCyWf2hRLwwB3BWdotosLPlFIL3cku2sYfdaJ9cP6lukPb YHdBZV0xj2zd8/uMpsJ7oh0WU15M17gVtrZBIIQRW01D/EuIkksdlugP/0ACBDb/MFR6 xdZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Amb6Km8x; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-106139-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106139-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z10-20020a056638240a00b004773575f77asi3183312jat.167.2024.03.18.06.04.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 06:04:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106139-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Amb6Km8x; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-106139-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106139-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5F5A1282229 for ; Mon, 18 Mar 2024 13:04:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 417623BB3D; Mon, 18 Mar 2024 13:04:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Amb6Km8x" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 72877381C5; Mon, 18 Mar 2024 13:04:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710767058; cv=none; b=GSU2GVVEt2hhmb4eN5d9OtOhsJwb8iRh/8N3bLnXUO94SGWQGlIJlx/KmeJqypTJUbFGXR++A3g+YCtZr3WWp9e17QTVl3erZ/Mtf1kq+S7L2bNxKXKCRCr73bWI4tdzB3XfRU30Q+7XuKCNR7nwWUZXSLUHYX6P5/qEgrGcjdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710767058; c=relaxed/simple; bh=iIs+cbLa7AHztJVkWHe+vnPyRdgwFNA0Lqe5a5IwRa0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Aeqlu2R+gVbPYQOhsfwSpZh+c5+SYfRcR0AelSrf/37jN/PsHS6v6uylBacXmlMijsiPHMUb6x49vh7N5uAl7i7oPsQxI+zO96pCVZo7i6vgv6N5+5gC09/DMixBGJAwTgst98V0QW69STMUGfcd+YH3jS46T8BVn3qo4QZRtms= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Amb6Km8x; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710767056; x=1742303056; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iIs+cbLa7AHztJVkWHe+vnPyRdgwFNA0Lqe5a5IwRa0=; b=Amb6Km8xI3D/TcLjyjwY8FdyJlPjqcGGd5qgyA/ir28TiE/5YS+/njgk 10M+5NTcTjIDCVwpxOnipJ0bSi55szr3SctfjX5p1ZCG6vsR0RwZKIOs+ aGCfbWyRugz9xGSQjIjZ7m1VsaZ7zh1TDMjxa9BVHnAEkR5tnk2oXsgAY mN9/AEFMv7pVUI1S/MPneN3AOwdCg2yzhUIbNxxRWTtAGRFHRIVAJ8pOp k3a+sSbfGhkXaoW6jeZR2F9iL2z/Y9xmtDUk6gJwWYen1x4Szotsq/TrP fwjt09leZPwQZz+XiM3GbtboHYp1GpEssGPew6648K8s9X3VuP6lpsSjs Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11016"; a="5707142" X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="5707142" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2024 06:04:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="44392867" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orviesa002.jf.intel.com with ESMTP; 18 Mar 2024 06:04:13 -0700 From: Alexander Lobakin To: linux-hardening@vger.kernel.org Cc: Alexander Lobakin , Kees Cook , "Gustavo A. R. Silva" , Marco Elver , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC kspp-next 1/3] compiler_types: add Endianness-dependent __counted_by_{le,be} Date: Mon, 18 Mar 2024 14:03:52 +0100 Message-ID: <20240318130354.2713265-2-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240318130354.2713265-1-aleksander.lobakin@intel.com> References: <20240318130354.2713265-1-aleksander.lobakin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Some structures contain flexible arrays at the end and the counter for them, but the counter has explicit Endianness and thus __counted_by() can't be used directly. To increase test coverage for potential problems without breaking anything, introduce __counted_by_{le,be} defined depending on platform's Endianness to either __counted_by() when applicable or noop otherwise. Maybe it would be a good idea to introduce such attributes on compiler level if possible, but for now let's stop on what we have. Signed-off-by: Alexander Lobakin --- include/linux/compiler_types.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 3e64ec0f7ac8..9506efbf2b8c 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -242,6 +242,17 @@ struct ftrace_likely_data { */ #define noinline_for_stack noinline +/* + * Apply __counted_by() when the Endianness matches to increase test coverage. + */ +#ifdef __LITTLE_ENDIAN +#define __counted_by_le(member) __counted_by(member) +#define __counted_by_be(member) +#else +#define __counted_by_le(member) +#define __counted_by_be(member) __counted_by(member) +#endif + /* * Sanitizer helper attributes: Because using __always_inline and * __no_sanitize_* conflict, provide helper attributes that will either expand -- 2.44.0