Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp211407lqt; Mon, 18 Mar 2024 06:04:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU7JOQW6dOJ0a2WBaaDxC9rk0Rp5ZKcnwtqSPuJVMBy7GpfJatAEnJsJ254vrOfOeqeWEaYNEhDJ/CsL8GGem+1MspYnwCmht3vkGabxw== X-Google-Smtp-Source: AGHT+IH5nBR+pDslwxshaGBh6DNuubdoEv4h3fKSlFW+wM/t1yrtNCg/W0VZfBP9FPtIVY80r+JQ X-Received: by 2002:a05:6602:5dd:b0:7cc:20b:a517 with SMTP id w29-20020a05660205dd00b007cc020ba517mr7806968iox.18.1710767068817; Mon, 18 Mar 2024 06:04:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710767068; cv=pass; d=google.com; s=arc-20160816; b=rBwUF3WNej55OomvxImdNlz1Y1FPLDwa5qxXmcOuXeKCP1FWxOjoQKEJrdjmaDPSNH Dl1LQez82nozyjuV9eJyDhelBExStp/TSwDdCHLHDau2F+ic/TlFpHXdGGyJ1YxULos2 n2gY5kEJgJBK1Tp5ee8oH1BMEv4zfkEY9AozFxq/4icm08l97cYl656qAuaxVEICJwCY kSoJxxR8hP5UjhTs8JAWDI0IEsgmIQ30yUtxobbSt8mxGGZp0ObBIXCdjbwlhcPmeezO 3+Zdg8+rFe1GEEEnBUECbT4ngdQ57BcI5SuqeaL9n6NWbExelQF5MMjT8KSsJHkQ92nE jZBw== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=ozdYdCh//y8M3DnDvZyv0OgpTBxioiMtJLRGsKYy/NM=; fh=iaMc8qbrcAb26pJlr23GcSFusd+aGkvIHrXDh3azOIE=; b=mloqj8QaABs4S79BvQCt5B4MZUb6NFzVRYU+UC64V54PD0agmMqn6NZtZZp/U5TJE2 lyRW8hGjl2yK2lG+q0u2r/3KY/3T2gnLzO2e1TduZKLwf/+LxliWSrOoZrE1ZWoUOJTO xtE88SDPL8TxDawTUxdG+zKmdjVQtIQ43H2wdyv/n/K/3PVb6tDO9r+ttt6mYmzqNhSi /x/8SRc4+gQXk3rrotPgoW34/y2EGtUs5P1IztNCTbIRm94PWuCw/6FzcZ0LEORMHsPg sCYrDmevzPdXiJnq298BeVHy+lk9DYxpW2TiBiQ0aT9AYqxSZgXEeH0/nqIaJsHJPGHw 766Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MFVwYSq+; 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-106138-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106138-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. [139.178.88.99]) by mx.google.com with ESMTPS id eg6-20020a056602498600b007c8a874f4c3si1560866iob.23.2024.03.18.06.04.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 06:04:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106138-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MFVwYSq+; 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-106138-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106138-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 55923281EE2 for ; Mon, 18 Mar 2024 13:04:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A13DE38DE9; Mon, 18 Mar 2024 13:04:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MFVwYSq+" 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 D5BD537711; Mon, 18 Mar 2024 13:04:13 +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=1710767056; cv=none; b=kR1568kmfgMFmmnCma+c42nYcT0TF4DkSTCdy7l9NZ01+KAf7PzJJvPl35grcZch5Am8CnZCLwsrAieqtEWWdd1naHrJnAgGmId/BX/qK0bGE56SQIMSL4VC/0sVkC/NWsbAup41pxHc0k43aEV58/38jTb6pd+gLlu2mOGO7N8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710767056; c=relaxed/simple; bh=CYdWZsOzq1pnl9m/WNdRLA7plSjBlkbbLINFudwQ8gA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iP2O6rCjATCcR/A28PFFVcMGILxdigxOhqz4A6fxqAIso7RqVNmRFx9BO6ax7Wei1oSlnYGQG9SpG2G0+1qXV1y6wPnmw5sKOZp9jvgY5wHK0g/0XSi8cQhSdtXUTTlP8qNNT5dbWsED+bknGTiuQUidue2LPAfgju3Tte3g8C4= 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=MFVwYSq+; 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=1710767054; x=1742303054; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=CYdWZsOzq1pnl9m/WNdRLA7plSjBlkbbLINFudwQ8gA=; b=MFVwYSq+NEL5KfkIr14tQutnzR59AXXdMdD4fAUojjqzuMUOFiyBk+fn MfDrC0SC51ycLQKfGbA+GP9c+linI93gZjWhS4crrFNsL5DV46gM+QZ0u tNaELut0MRZqwvfmayno+KE2FpSXLtnU9MgJqWCDnDGz7NEGhFsIofSXF +z/O6XM5fLV4FiM8VFWW1qtYzMFaSRFwdp6kZUk5BJN/KZovsFSrKYzhC FXBhPCGhuF6yTgzomHb9dSfbxUhu1/ZWId1Y5Y9m0pd//Zk0kGoiK4udC IdLa9TKYXGDovWlg61w10kpeV1VZZ6k8vODfOqyxdrJGILazgEp4Nvmd+ w==; X-IronPort-AV: E=McAfee;i="6600,9927,11016"; a="5707133" X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="5707133" 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:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="44392842" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orviesa002.jf.intel.com with ESMTP; 18 Mar 2024 06:04:11 -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 0/3] compiler_types: add Endianness-dependent __counted_by_{le,be} Date: Mon, 18 Mar 2024 14:03:51 +0100 Message-ID: <20240318130354.2713265-1-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.44.0 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. The first user will be virtchnl2.h from idpf just as example with 9 flex structures having Little Endian counters. 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. Alexander Lobakin (3): compiler_types: add Endianness-dependent __counted_by_{le,be} idpf: make virtchnl2.h self-contained idpf: sprinkle __counted_by{,_le}() in the virtchnl2 header include/linux/compiler_types.h | 11 ++++++++++ drivers/net/ethernet/intel/idpf/virtchnl2.h | 24 ++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-) -- 2.44.0