Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5027706rdb; Fri, 15 Sep 2023 23:11:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZtW5LtkVo5IsCAmfw3FZ1n1cKZnv9+CsoJKVJyzuoMill4PcN5R06TzfFuqrEshUGY9Fa X-Received: by 2002:a05:6870:568a:b0:1b0:649f:e68a with SMTP id p10-20020a056870568a00b001b0649fe68amr4965808oao.25.1694844671320; Fri, 15 Sep 2023 23:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694844671; cv=none; d=google.com; s=arc-20160816; b=NJGQ2u7sH1i4mowa87u7seMl8wpKe0facCg0WBopFOPRVWNWFInoX+QJrQActubhkQ plvksSeVHtIWJRx5BJGM7Pc0pYuEZM2t6D8jsDcoVzQRW3khkLfz16ltZ5yraA8zl1sr VhPnxYjqQZAddiQbLLj5S+5wCjjWwsbjLBHpvTmMz0Lho54W1A4QeGWBK0so+8XS8767 03w0pM+DhFYGUl+TykYmudF8QsjmyQlSX5/tChXqx5vYOlFZLfZhjn7p/XlphKQpSdXn X7rcitllJM6cNz5yx1eK5K+zmO9JLhZLCB5RWud2ffv+6J7gZdqpT7pN/yZx9cC7tlZp gNVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5U9yAMmxUGtlu2RTV+opnsRR/vKyQ1Eg6VpI2oRXqGs=; fh=QE7mRW2I063D3J61tnUblOMpENXqZHVBuHQxVQ9ppr0=; b=vrXIDaz9hUuuMfWfw4dJwhF+oF5/2XujBEMvVsuflScJv3Px+4h4+Bd5NEU8fy3Ct1 1ytfYEgmT1H2BvI4MJHFhzMVAbL9sG0e2wEo9QWlAYUZUR9nBa23HF5DfJKP8rRWrKlu yRqe2SCP6AG9pFm3XMTl+SGYzioBF+aPr+WytMk564+7TkdO8HryoNdAleTX7TF4meFs IkSHzJZEvrrZmxYq9GC23W7dvSrW6+5jUSp65Eh8YuODap7moKU5WzAPC15LODropTcK r3KORbEO1Kv43KwYRFpuhza384ll4zOK/6Vtr+uNFCQEDWs7r7rLMEf/e5joMzcnKa0u UGFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KAmubKzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f12-20020a63100c000000b00565f7784bc9si4257504pgl.186.2023.09.15.23.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 23:11:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KAmubKzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E58A38342195; Fri, 15 Sep 2023 13:17:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237226AbjIOUQs (ORCPT + 99 others); Fri, 15 Sep 2023 16:16:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237143AbjIOUQ0 (ORCPT ); Fri, 15 Sep 2023 16:16:26 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5D9D3C26 for ; Fri, 15 Sep 2023 13:15:30 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68fbb10dec7so2356707b3a.3 for ; Fri, 15 Sep 2023 13:15:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694808930; x=1695413730; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5U9yAMmxUGtlu2RTV+opnsRR/vKyQ1Eg6VpI2oRXqGs=; b=KAmubKzx8NgJFenHA874q1LD61JK7Y10xRge5wQGTGZYqkXIt0FNRsL+ExPJfy1A+0 sLj6OWKx0fcCoAkUf/gtePg7Za7cb7NDxiGY9xrQbHvUqrKNcX4+EIQ77EXfPkYO7hG3 n0ecJWgDnJ0kqISTSTjPbPKjNMvXOTxUTwOiU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694808930; x=1695413730; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5U9yAMmxUGtlu2RTV+opnsRR/vKyQ1Eg6VpI2oRXqGs=; b=oWe2sbXd1H/3nHiTPl1/8a6vpQHz99+azzor8jOaVlK423GTBhFlJOp0KEmLOpuna+ nzcrPvSZ3qiIZHAqiY0BH/Igi0LfplKF9xLP3WW4laD5qdwDVFMhQiIYIbhlSKjrG4Np EHczt6CDlN8p8XSblzPADP3FEEj83S5WiVQuWwa1wKOmZTffbv2VQEI24SGgcLRsEfck gvG5eOnOvGwBzRfVcWiL79JxBmkqzSa5lzVIwVmxLA6/pNZKVuHkZlGWFDfdRhyek5dK ld6Ze4+kY7WENBWjHFYb+Nc81dJkLzNRrY2PS4zMNDmu8os1Ica3Sl+u/MgzxyHoGhG6 rmhA== X-Gm-Message-State: AOJu0YyrYXxyoZJ1DcjZsMDFyw3LwQfKooLOOicQY3RoG5hHtkSo4Kju PNfA6qWkC7VlxWNfgdcGvMCDAg== X-Received: by 2002:a05:6a20:2583:b0:153:8754:8a7f with SMTP id k3-20020a056a20258300b0015387548a7fmr3347558pzd.4.1694808930405; Fri, 15 Sep 2023 13:15:30 -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 u4-20020a62ed04000000b0068fb9965036sm3308876pfh.109.2023.09.15.13.15.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:15:29 -0700 (PDT) From: Kees Cook To: Mark Fasheh Cc: Kees Cook , Joel Becker , Joseph Qi , ocfs2-devel@lists.linux.dev, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] ocfs2: Annotate struct ocfs2_slot_info with __counted_by Date: Fri, 15 Sep 2023 13:15:23 -0700 Message-Id: <20230915201522.never.979-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1167; i=keescook@chromium.org; h=from:subject:message-id; bh=vVg/lwd/xTHPf1ncyCo+ObbQAlMJgY5cAnP5s625GBY=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBLta7z/D+qrhNioYhLhzv1EUA9eiYGgPkff5E WkJ6ZVV9kOJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQS7WgAKCRCJcvTf3G3A Jm5LD/9AgxrbRwWNmusFfPJ9QxfnI7oMtHew9CbcXH9J5762zPWuOe5jVw8WhT+uByyd1i1mixz 5el5s969WpfACTpAWuJhC/dB7M4vQwfkdYngKRmI9ur1PJ+4t2AN44FzbEL0g2b3dm2/nYJqU2B 6Bn0Nq+cC8LlgpdU6T5vaEUHoMtls5+suDayovc5HuVQiWgA63f0jqxtvXW/eXzZ7PjtEuZrvut XMJyOwUDGcR86O4hFOt3lBOxZB/WNl/iYEJiAjksnRhkdshPp4fXzHQTxaHF4VgS993Y3T+1IWV 8GlRsZ/6SOwuRU8ZyH3298IY06+Ri3SP6ZGZTdDYELWaSBKTxDG8PTveGNZKjOy+whqwYugCb4p xp7eLci8exro42aA49ZptpY+0KaTLA10QN78NVp9rsHmzi1dV7bX9FbkeAk+gVE2mcy+iDmc65O 6bLjfR2vvXY8zgk250FYcXj8HrxcGjXAjw8ZWIEFRjY9IiH+F+8aGhc7QICsw/u0gUDjWZskoa2 6ir7iarUGsxSiSF0PfeRvgLppdp0iyrKw6u1FIdu1hVbHgTwK32rVJP3eENfmy9GK+DZrEKnVOq wXmADnU5lgUCfc3hTRxQhalNw9D6NVB3UClIcZ3ZI3ve7LH3ObESB1Q8b/RkX/Ks9y2PWyYg2Bf x8VFe1R RW1mYTMA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 13:17:15 -0700 (PDT) Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). As found with Coccinelle[1], add __counted_by for struct ocfs2_slot_info. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Mark Fasheh Cc: Joel Becker Cc: Joseph Qi Cc: ocfs2-devel@lists.linux.dev Signed-off-by: Kees Cook --- fs/ocfs2/slot_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index da7718cef735..e544c704b583 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c @@ -37,7 +37,7 @@ struct ocfs2_slot_info { unsigned int si_blocks; struct buffer_head **si_bh; unsigned int si_num_slots; - struct ocfs2_slot si_slots[]; + struct ocfs2_slot si_slots[] __counted_by(si_num_slots); }; -- 2.34.1