Message ID | 20230915201522.never.979-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1377380vqi; Fri, 15 Sep 2023 16:23:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJqS0g5R7K8n7PjBlR+YNdOpGYz2nZkYS2rCmJGB+nBU/4RX3HqQTokQIV9egjJF4J+YcZ X-Received: by 2002:a17:902:d485:b0:1c3:9764:764f with SMTP id c5-20020a170902d48500b001c39764764fmr3241625plg.48.1694820189244; Fri, 15 Sep 2023 16:23:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694820189; cv=none; d=google.com; s=arc-20160816; b=P/211RMXlreeQhJU9gMqz61RRRpvLRi94SFYiw4giQpiVIUHW+LyJmZRri9ZkzYSdU cE5LQolNkbCDCmyKXPhK6uMV9YqjDT13mKYkiSMHgYOPs8qE5rtox4vxiK+YsGXES6Ec wjO2fndOoqonjn1uNsNYyizDq/PYbNutzbjXfcPrisAhMdGvkNTb9HLJlZJ8oDrf/4Ks QzspTagaUQlbhrOfkC2NsvF05hVVhuDJyxmPOL9UgWJkai+Slx509HqKIXXWHI6d+fUf 3ehmU9B1iJPBDjFNRiMD7lDtghk8xmYWgRBfk4+ihIfB/Ag1HdUQXe5SAABpAj5fvOsI 6/QQ== 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 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id u10-20020a17090341ca00b001b89f653005si4342923ple.394.2023.09.15.16.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 16:23:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; 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 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id E0CAD80293DC; Fri, 15 Sep 2023 13:17:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237228AbjIOUQs (ORCPT <rfc822;realc9580@gmail.com> + 29 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; Fri, 15 Sep 2023 13:15:30 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68fbb10dec7so2356707b3a.3 for <linux-kernel@vger.kernel.org>; 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 <keescook@chromium.org> To: Mark Fasheh <mark@fasheh.com> Cc: Kees Cook <keescook@chromium.org>, Joel Becker <jlbec@evilplan.org>, Joseph Qi <joseph.qi@linux.alibaba.com>, ocfs2-devel@lists.linux.dev, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, 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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 15 Sep 2023 13:17:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777139079751647102 X-GMAIL-MSGID: 1777147775189346022 |
Series |
ocfs2: Annotate struct ocfs2_slot_info with __counted_by
|
|
Commit Message
Kees Cook
Sept. 15, 2023, 8:15 p.m. UTC
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 <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: ocfs2-devel@lists.linux.dev
Signed-off-by: Kees Cook <keescook@chromium.org>
---
fs/ocfs2/slot_map.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 9/16/23 4:15 AM, Kees Cook wrote: > 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 <mark@fasheh.com> > Cc: Joel Becker <jlbec@evilplan.org> > Cc: Joseph Qi <joseph.qi@linux.alibaba.com> > Cc: ocfs2-devel@lists.linux.dev > Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> > --- > 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); > }; > >
On Fri, 15 Sep 2023 13:15:23 -0700, Kees Cook wrote: > 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. > > [...] Applied to for-next/hardening, thanks! [1/1] ocfs2: Annotate struct ocfs2_slot_info with __counted_by https://git.kernel.org/kees/c/7c993785ae63 Take care,
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); };