From patchwork Tue Feb 13 23:42:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 200756 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp890098dyb; Tue, 13 Feb 2024 16:16:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUekXcagkG9kW2cjqm6X6oHzOIHpF+yO7PmaXOqTn+kBNAwxgCM0rDpSv1dIU330hobVZRe/XKGv9/XC/Dzf0e1MjQnGw== X-Google-Smtp-Source: AGHT+IFQR3UFRxEZpbDUtT6PXdNH0wuk/uz+sGYKNHTvk+59DnErzONDi7C++0Ex+Zx5t+FOWALn X-Received: by 2002:a05:6358:e48b:b0:17a:b810:aacf with SMTP id by11-20020a056358e48b00b0017ab810aacfmr956102rwb.18.1707869811631; Tue, 13 Feb 2024 16:16:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707869811; cv=pass; d=google.com; s=arc-20160816; b=OX32rjUtOq/KGTV5YGFc0W8puIlSRjPiPU95Nv6IMK4FYu/eOu0sfpN/d08aR9nncf OCUW7RKtHiMR049xlwlhOFXczw3aZ/90dmpCuRT+gNuiaIZKGr690OuF7vNZfE5+pRov SijTKg6u67wCa+TFajnG5n/hpcJtirF+U3TgZi5OPC6dYyVvtomFYexZMwWpolUu5Ec5 J/c4MtCa5kkGUoEaWDbVMXNbT49EgblbfdHNQYZjmgTDYfQA5nEjCYLweGQ5AaPVhcYO W8EEwL2ZMsN/dUJU4A3QTThHwT+qhRTYHiaiRUY2MXCw7PNstnm7Em1/Wd3ls6fQmezd 3/zA== 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=Kl2LWzzN8MyLhz/HbCD4r7+bt4+VkpQDGtXfFs0staE=; fh=urZRidxM09TF3PepO/twmhYEVAMxXqkGlLwv7yAH2Ww=; b=h36GJPlU9aPMzz3ob0EM2XQZxmdP2kOFC9BskQAt02AHTLTJ61u+uM2X0MAPpGkiRp I4pID6+Sluo3YRy7IR0q80pKXIJTjGwZ4FotkavFcLmwng2IUyCqW9tIZ6yCNnaAwENl F0MNHvhSPevpx903BsZCv76CVoUJ720muRf+uAf7Y1UsbS0GSehIA7ORu6DACq/53Aar wG3R3wmuqipDAe1WaMMEX+YU/hp1QNg0kDj0+7Xdf/WX55ugkKn0O3EDcsjOLOBHGgFx ZJqBPj/PnM3YltquubRfNxjL698FYVu7F+S3zwiMvguEwdQfopg93c7Yntzs8lot3VyC P5Sg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=anNxmPUW; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-64556-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64556-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCUHrLupapyRRU/TvCvcuePSmY0Aw8sqaKeh9NGNRCdVCctdbsp1XUI1ZiGKdtMb9rpQdhP6Fn0aRhcFqM59E/uv9UUALg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d63-20020a633642000000b005cdfb96ea62si2716996pga.243.2024.02.13.16.16.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 16:16:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64556-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=anNxmPUW; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-64556-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64556-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 38A02B20FF0 for ; Tue, 13 Feb 2024 23:43:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AEEF64AB0; Tue, 13 Feb 2024 23:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="anNxmPUW" Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9195C633EA for ; Tue, 13 Feb 2024 23:42:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707867736; cv=none; b=ZUbYpNm9Oy1RNEmdSp+VNF0cLoJEgK5EXg1typMs3STF1q68OT8+Pm/FBvQpqJVkIC7ePRF0RDxJJmlGJPQNfGdWJaeiAPuLXbc+GpArJvT74a5sNJoMY4fUM6eaJgGEhXyBoxKKXmZfcbob/nEH1woJgaekfGQQCehWV86XANw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707867736; c=relaxed/simple; bh=Vl4fdN5cpGUJaEVd/d0wmt2xUmRLpJ113oXlwnbICno=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jKAlUX/DE9/0adPkKFOK3TruM+bP3Xu5YGzno7Zg5RCxq8ZWcg+MZlmvrPsvwjNOnEfg5fnWMpu6YWuceJweGWag+7ojSK3M7/m19D2HS9OShGj+AUtb2sevjE0L1KzSRvj6UbWuAyE7BlRAWCuRr0sdyNwzyn+WBlZD7WTj2dQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=anNxmPUW; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1d94323d547so43245345ad.3 for ; Tue, 13 Feb 2024 15:42:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707867734; x=1708472534; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Kl2LWzzN8MyLhz/HbCD4r7+bt4+VkpQDGtXfFs0staE=; b=anNxmPUWkU3k1Bjt6yqXzcrBgXBU/ObGoY2T/aIAOR1B9z16vYkTAlUFm+TwSigNp4 ztI/roP6UEbWOb3qZsZbu569DPRmQb5aFwUeNxmn7WGjpC6kl26r/6w/67dPVCtAwHSI RTO0Hvnz5t5/RNg61LmRekTikwsUtFVu0NCAE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707867734; x=1708472534; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kl2LWzzN8MyLhz/HbCD4r7+bt4+VkpQDGtXfFs0staE=; b=v6mKDc7Zu1/JxJUt11//cTVl40sHROLmf1GnbM9hndwSQE+5cNfUmUP56ivhaKA98u VbFDa1GpI9JC4WmOMN5zdNUt4YlZ+0LDgp7YcVQCpzz74/PE4/yN85ka7vSCGNoesxKR Yj5RWd/YIOungjX/Z6mIZmUxBdqguekL2tmgk0XqxtXkuHyn/nRgwjzoUBEI/Jeo1mPi +RSvxFDMvETmwj1ToOaR2WmJWix9Z236Yh5jQAVa62eeq+4EanaTBKtfRyM+Z1V4NMm6 KdmRTQjLTpSHWnw7Bp3zBktUR/qybyUcN+F+yBthE2ubVw8aqC1viX+e1xbwClNv3SUy Z6fw== X-Forwarded-Encrypted: i=1; AJvYcCXr+6Tezc7bENbPVWgpcp1/KMBojLYYWrF8+KB13cABdKwH3VHlfMllDBg3XWyyBO6sXDPIHpWiR0WPhHrP4iY/tGjg9GOepr3Su+zT X-Gm-Message-State: AOJu0YzSYoyhU9PY6/RaJxikJvsjZSK6W+a1GDH3ahtX9oOoHp+icPY7 tnfof0WMKoGFjPP6VKmP5mDzNGmAqxmPj+WEiY4YhgH6wXjf24lCt0xwzImZJQ== X-Received: by 2002:a17:902:bcc4:b0:1db:4213:41e8 with SMTP id o4-20020a170902bcc400b001db421341e8mr1065887pls.69.1707867733891; Tue, 13 Feb 2024 15:42:13 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWz2viB/lB71RPgqINheT2b5dsUoRzdQFbqLreZCRsMJA1WJTSmCqzNAXQ8vLgFxvOITSdL2S4gjMc4StKNV/JfvxTXTTXrlo5SSaausKtQswwku7LybJtVCBL29himU7p5+kc08BeX+Ws+9mnpIIBnuU66RCW0Rp6mdgPvcP1ILo0SOqJXDhYYLpxVqYLq2wyrno0lCVhb/xijD9bMYp7EjFbnCazl0Zl1vNYijxJjmeJqYQ3Q4nevYmj3dT7wYeGjD038BIWd/Xb3aMJuzSuD3XoacGI29/SWgAgY/xggmiXqFSJLfx7VYz1n1qhh1M6aSWgB0SAwuGE/irr8fxB2j9Di/AnLTwC9zwV8F4rcp2VwvXkE3XK1Ut29nN18l8Q6T+YGpSSCNZHX1E0qfVvC6mobsbSFo7/HPP/fgsJIw+DSUGp+qucHlCLcTdwycYSQMws88W+NzCNCrkkaWUujD0WgNQxcwvRKki35FgBqofesb5nitL/dTtZv/jIQ Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id w2-20020a170902d10200b001db5432449esm220101plw.18.2024.02.13.15.42.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 15:42:13 -0800 (PST) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , Rasmus Villemoes , Dan Williams , Keith Packard , Miguel Ojeda , Alexey Dobriyan , Dmitry Antipov , "Gustavo A . R . Silva" , "David S. Miller" , Eric Dumazet , Paolo Abeni , Nathan Chancellor , kernel test robot , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 1/2] stddef: Allow attributes to be used when creating flex arrays Date: Tue, 13 Feb 2024 15:42:10 -0800 Message-Id: <20240213234212.3766256-1-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213234023.it.219-kees@kernel.org> References: <20240213234023.it.219-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2745; i=keescook@chromium.org; h=from:subject; bh=Vl4fdN5cpGUJaEVd/d0wmt2xUmRLpJ113oXlwnbICno=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBly/5TQc6E64Lzj29qmQN4Jwy7MrKuI/F1MJFh2 tmtoHAY6iKJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZcv+UwAKCRCJcvTf3G3A JrCAD/9dUQyB4Kg2htW/OtV1/JApegYxWNiu0BRZxvGYS5pHECr/K3BxDugfXOko4/zESjBoXjf oKne0LTCU+n6HuPlWp6zmQdUyux22FU/GI1RK+CAPWxrDo7Eoaak9k5mVZlkyE6LD8Ur6gpQnYQ 5spQWCBBmJPZBxZEbArwX9oIAyueehEhaKnNnpuOwLwS2n3uItshYSU0dl7bHLiykxU9IhDOTS0 Addl13oIkvwVsAGt5fSXKor/Yl5ngDyBFQIImhm2IyFU2lGqVhjJLrEA5y86fHBxIwzpNQLn1BF b3VUXrW7G/SWYh/zz8T2miyJkQd68mFy0Qg8LOYVe+dlxtCoaq/TCB0mL1aFBOsSces26kbUWGK KydqjzrCcM0VZ7KlMxbCydJB6nQEEDt/PvalBi0LVIor3+9kPuOV1lzkMK0GBDM8ZdhG3GtbWxq /yQA8FhQA8og1cCFordZak+S9xid/nf2DXzA1/pa8ZkwJyMfOMAKvz3pNgKLfFSER+p2CSY8+Hq HWrc3oXSv5OmGw4mxX7QFe28Z89lG1Zx40NxOU7khlU4GWSK04QnxYjfxLwcF3HEHNhnBHuGjnw 10bvJcrtCAtn7+5deAIUPhecENMUcoNsCrhff7IvMnLS45PKWWnb5SVt0DCqvUxFHcmG/wPnyPF PQc/zLP/3RX7jkg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790472723873075075 X-GMAIL-MSGID: 1790831295488302022 With the coming support for the __counted_by struct member attribute, we will need a way to add such annotations to the places where DECLARE_FLEX_ARRAY() is used. Add an optional 3rd argument that can be used for including attributes in the flexible array definition. Cc: Rasmus Villemoes Cc: Dan Williams Cc: Keith Packard Cc: Miguel Ojeda Cc: Alexey Dobriyan Cc: Dmitry Antipov Reviewed-by: Gustavo A. R. Silva Signed-off-by: Kees Cook --- include/linux/stddef.h | 6 +++--- include/uapi/linux/stddef.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/stddef.h b/include/linux/stddef.h index 929d67710cc5..176bfe8c0bd7 100644 --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -82,15 +82,15 @@ enum { /** * DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union - * * @TYPE: The type of each flexible array element * @NAME: The name of the flexible array member + * @...: The list of member attributes to apply (optional) * * In order to have a flexible array member in a union or alone in a * struct, it needs to be wrapped in an anonymous struct with at least 1 * named member, but that member can be empty. */ -#define DECLARE_FLEX_ARRAY(TYPE, NAME) \ - __DECLARE_FLEX_ARRAY(TYPE, NAME) +#define DECLARE_FLEX_ARRAY(TYPE, NAME, ...) \ + __DECLARE_FLEX_ARRAY(TYPE, NAME, __VA_ARGS__) #endif diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h index 2ec6f35cda32..028aeec3d7f1 100644 --- a/include/uapi/linux/stddef.h +++ b/include/uapi/linux/stddef.h @@ -31,23 +31,23 @@ #ifdef __cplusplus /* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */ -#define __DECLARE_FLEX_ARRAY(T, member) \ - T member[0] +#define __DECLARE_FLEX_ARRAY(TYPE, NAME, ...) \ + TYPE NAME[0] __VA_ARGS__ #else /** * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union - * * @TYPE: The type of each flexible array element * @NAME: The name of the flexible array member + * @...: The list of member attributes to apply (optional) * * In order to have a flexible array member in a union or alone in a * struct, it needs to be wrapped in an anonymous struct with at least 1 * named member, but that member can be empty. */ -#define __DECLARE_FLEX_ARRAY(TYPE, NAME) \ +#define __DECLARE_FLEX_ARRAY(TYPE, NAME, ...) \ struct { \ struct { } __empty_ ## NAME; \ - TYPE NAME[]; \ + TYPE NAME[] __VA_ARGS__; \ } #endif From patchwork Tue Feb 13 23:42:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 200738 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp874423dyb; Tue, 13 Feb 2024 15:43:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXBlk92XWKawaoA/V76aKW6aogkstxKCvSyMqCb0H4rWc4ampfHMs74PCj7QbB/e6LGN93RKLcvTg8ipm6HHbzYGq6bzQ== X-Google-Smtp-Source: AGHT+IHEx1N9H6KXNm29vcFPLlbqjaAh1f800hZbzOdGYosdZb8B6GJGk3DrisVjTEw2kn9sA35i X-Received: by 2002:a17:903:2a83:b0:1d9:7729:2a6f with SMTP id lv3-20020a1709032a8300b001d977292a6fmr1298322plb.61.1707867793571; Tue, 13 Feb 2024 15:43:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707867793; cv=pass; d=google.com; s=arc-20160816; b=Asyoir3Eg+vPzS2DyupDbl9Bs1VDDA7LfKTC/nm+RRI3ZF9PQ7A7PVDg0/CkV0U+se ZVBD2mCFdgSlQbC5dpBSpoZUsKfSL+lCbzmLg9TA0wlktV5Dl+xKOXUZWFqgOJWMs/nu eTiJCBPdeZAOIWfB9PMS4Bvzxd4azQg1C9aAx8GbNQOhiL3w8yoZmibttKd6Qym+du1c fZ3ZktCC50+JegxLnJ+U66jY6syK10nwBPa1Myarl7eiKBJK4RQrAj2k7+1ghbgSUu5J +w3/FXWpBsppuwVSlj4jogSaAGUhfL5yINem3HdjCnNsCxWXZdRpV9T5pzALpq2il7Y3 Du3w== 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=in33zmkUwO/lJCZx5ql5VPHI+fJoeC5L2QBdGV5S4os=; fh=h8gfD77bawP3YEZexPW1yVTb9A/lmtWDQ8ivz89nzBg=; b=ihNBEREnV+vL3++Ol6DzZilA17BYqhQnNj9sZj4sRW+yE6WSsYvYKH+q9VQmqf/Zd5 JiAbwYT5hk8UuuuhbyPoIeUWb1aFxxKhogafEWank8CDcfC5cm3J1OFO9lmbnA/nNfl5 XHndmgxJh+/ug3XDvCN8Han5nrk7MMu8oDCPz3O7/DDeRyLC5lkVJA5EFJhF1LQ1b1uh slmb6bhgCVzy2kyg4xTr0/9CHLPy2x5ohh57f8HLtWnXBq4TQrfwwD9NhiQRmwWlT1e2 mIGFb24TgBpl/vWzXi7ipWa9jdfnkiu/BYCkE7u/I+IcQ7g0oX9n9jNaJ5MXgRRLFzns Shxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=heaiVvIL; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-64557-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64557-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCWVPd3zljcGujwcEp3sszcz9YxC5ayL5IScIMsheiZAKhpi5mjqOpBj0TC6iwAT+bFk81wYeEmK72H6NZEKa7lOVUlD3g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h14-20020a170902f54e00b001d8f3a2e055si1525235plf.177.2024.02.13.15.43.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 15:43:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64557-ouuuleilei=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=@chromium.org header.s=google header.b=heaiVvIL; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-64557-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64557-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 553F428B5CC for ; Tue, 13 Feb 2024 23:43:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27EDC64AAD; Tue, 13 Feb 2024 23:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="heaiVvIL" Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B540F633F0 for ; Tue, 13 Feb 2024 23:42:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707867736; cv=none; b=L+0BSySGymmX2yZqRYpu/BKtW8wa1BBv2/RHQt8vRsNBMgT/YGqlrtujsUI6+jlC3H2WE+Xr3bpl02wWY8ggFfeq0Mv4OUkXgiWMIxvcXqsLk3necFsnYkFII8yiw4/dkYPy7Q9SfbrgGaDPyr6mNYgjVUPeziY2YwowFBbPe1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707867736; c=relaxed/simple; bh=JaLcS0MhnhYo6HqFOcWGWSj+KGWfIIInyL0CMdYPrLw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MaRGE4ljqPwMcoECiSASIWd5OP4VomotWPKuu/PldY4gXSYVcskgM7u+EqyX8jXM4fq7RdtCu+dFYYi2gjulZ1N5XEvtRL0Vc1SNEV3n1WRTv0PvNzMjqJoUs+1aDoRff0U9a4xqa8OxmwbmHzyfMQawUxUHhGHrG0D/mcrNbGY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=heaiVvIL; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-290d59df3f0so3575215a91.2 for ; Tue, 13 Feb 2024 15:42:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707867734; x=1708472534; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=in33zmkUwO/lJCZx5ql5VPHI+fJoeC5L2QBdGV5S4os=; b=heaiVvIL7p1+JZGvP0iOwvDgcGu/fxW7meOB/pjLgJAoF0/QXH7oF21t33SY3q3pXJ yDnjXvn3Gt8+Ea1HD1xmZGB94kGDzp0lMya85g8nqhjiqlbt+jJw+mVdt6g62zDTpo1n ctP5yc/UOPXm/VYSB5cDnwNnwy/D8FhB3u2aI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707867734; x=1708472534; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=in33zmkUwO/lJCZx5ql5VPHI+fJoeC5L2QBdGV5S4os=; b=HrrAD+zLOax5p6wHaJ3P2pDGrFYmSVYNcWTtzcDJl/FQhzWs0o/BFwx4No/kE/zmDd kKyIhtGmTcqvPAIVJzHW+ASMKk2FIPNeix7CcqBewOjwOeUkOORS48jbbHxPE2gxZJrR ZqKviJDJxyMBbXeoNZaVqTdrw8DX9y2LcEP/pX8H0UlcHHAcGemEEY0X8/Fn/qFu4byQ DOEy8sRPIaZQE6qrLd6lBfijJPquuTKLGLiVypn3ALd/tcUuDW9XHAlECQnylVRBia0w gyqGKbId9a7NOxYkIwit/j/tp+8MiRr15WRtVDC3cPt6W3yxx65HmgjeKCx13Ti4+tjt bg6g== X-Forwarded-Encrypted: i=1; AJvYcCXOJQqCRqRU345KPkacLRIbuBotKJKqSNIIlA3hWXw6nIFwSqTljM3bYmc9ME5oWdLYuu44qxSYF4xwItXAvz7Akk0hVIqS+wsaL2cW X-Gm-Message-State: AOJu0YyGr22gU6rV/PVl4EH95UQcEMRysEIcMdQTigJG5B8Q9KzvEDfa DsNvRqCuWmOSzF4G5Lo118H4AAfM8UjzM7lCYUuKs05tWIidbsioptWiALVoNg== X-Received: by 2002:a17:90b:205:b0:296:892b:4c0 with SMTP id fy5-20020a17090b020500b00296892b04c0mr963267pjb.41.1707867734152; Tue, 13 Feb 2024 15:42:14 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVlVHC1f//hzKVyajZIa/bmyDWH5OQtGUzqsr7wgHc7Wl98sibIfjbfMPN1ydIq6ub1TlcIzCDSFA3iXjUdbeDDzsKqqfzpbT+69BWdJ5tIuPQSp667cZav30hy9odQq233bRml1rpMox0+VHwWhXt05zA4AI4b4mpzbY89rm1HAQzAG7Tl6BNMddRAIwzAcx7tYxnjYGb0oI1hdSdFybB5KKyLqVS5zaEeeDKd2n3VxWwJjV1zekHCmDRfBbtO4enBbIYqFxcpcDNFWrZRtxUVV4I6NQJsVgmOpX0kfTFMV+xj7aNsyIxrSuVMcsdGGwYoTO0C3w546gK4aCssnIdxn9DoE1V0CcXvJHpazg+zsgTWAJm5nz8VuzLL6m8SSOZzj0eJAr0iF6APm2jIUn6882qgS5bguwQXCE6rhN3EjAJsny79IHwcHRs2+m+4iUrKnkAhDTXdeBGsrL8JfZktsMjvUTLzG0opYjNjMn1ux70JX2pVBbys+rlXb13/ Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id f20-20020a17090ac29400b00298c06d843fsm84671pjt.3.2024.02.13.15.42.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 15:42:13 -0800 (PST) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-hardening@vger.kernel.org, "Gustavo A. R. Silva" , Rasmus Villemoes , Dan Williams , Keith Packard , Miguel Ojeda , Alexey Dobriyan , Dmitry Antipov , Nathan Chancellor , kernel test robot , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] net/ipv4: Annotate imsf_slist_flex with __counted_by(imsf_numsrc) Date: Tue, 13 Feb 2024 15:42:11 -0800 Message-Id: <20240213234212.3766256-2-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213234023.it.219-kees@kernel.org> References: <20240213234023.it.219-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=965; i=keescook@chromium.org; h=from:subject; bh=JaLcS0MhnhYo6HqFOcWGWSj+KGWfIIInyL0CMdYPrLw=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBly/5T7cTDxgTr0rDIqvT3vhjqivyAqSR9MrmXk vJe8ulo+06JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZcv+UwAKCRCJcvTf3G3A JjLOD/9kSRrC1i4wpx5fWHuu7VPgWHXMKYgp17lT1gJYIk6Ae40EuhyRDJZR+MqkiW8msoUquzA cDzdbDz26Z0dJgcnpAmerx78u08EYTTHrYMUaZI00fnzYhfO7GrKKNQ2o4i4C2BOt3IuiO1CbMP zJ4di3CiyGy71ooSKn08Z3/5pTLNAdmig+gl3GP2GNI2U5ny8OHZOOdSXxbaaM5059spgeEdSPF nbU6vXD4q5enmZH3V9CBHGOG/uXxO4okDQDH1y0gKDJu/PQ1foGcmqtqlMoXCMF3bKvq4/eiQ/B dTPsR8alCW97wnaa+pi6F8SlkVC8XmxMghe18rGMMBLVOuh/IS/ypL5K0b5TCPKZ7leqWFiRUEZ Vd7OLDIFl2GbI84vzx4s7kbcM9rhX7ADl46J55D0+xFomlstdpJSJapDvEonhrYUda4b18+paY/ 6a9OxcX4ihmoNr83RlW/n9RXCNtBVQin+GylpP5LQvS07iQ8GCZhy1qr4Uajq1qaffdIDYwSS/M FMytHRtpsPJCOMq7evN65jd5bn82KKnoKnoIx/M/IyePgJy3gKPL6+lVP4YU5db/OgXrvDxuFM3 Bf1sZ826NZDOgvVq2QlC3wP9X3CDLTVHF4Ab4de9u15ky7gTRZMgYZ8CpdLqudDhJ3PyovS9e5S StLpaZfKQmBlPeg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790829179714640774 X-GMAIL-MSGID: 1790829179714640774 The size of the imsf_slist_flex member is determined by imsf_numsrc, so annotate it as such. Cc: "David S. Miller" Cc: Eric Dumazet Cc: Paolo Abeni Cc: netdev@vger.kernel.org Cc: linux-hardening@vger.kernel.org Acked-by: Jakub Kicinski Reviewed-by: "Gustavo A. R. Silva" Signed-off-by: Kees Cook --- include/uapi/linux/in.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h index e682ab628dfa..2f0c4d40bc7b 100644 --- a/include/uapi/linux/in.h +++ b/include/uapi/linux/in.h @@ -199,7 +199,8 @@ struct ip_msfilter { __u32 imsf_numsrc; union { __be32 imsf_slist[1]; - __DECLARE_FLEX_ARRAY(__be32, imsf_slist_flex); + __DECLARE_FLEX_ARRAY(__be32, imsf_slist_flex, + __counted_by(imsf_numsrc)); }; };