Message ID | 20230915201413.never.881-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 h50csp1439350vqi; Fri, 15 Sep 2023 19:27:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/CO3FFUdZ1jFqjrqCInQqobFQvwTB3uOeoTGkvMB7dm3KnvHXZ5mi/hVUxx91DkGYHCaQ X-Received: by 2002:a05:6358:3426:b0:142:d04e:59f0 with SMTP id h38-20020a056358342600b00142d04e59f0mr4359614rwd.14.1694831264647; Fri, 15 Sep 2023 19:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694831264; cv=none; d=google.com; s=arc-20160816; b=QPWgWaTOduWFjF+JibImit7HoSTM3INHw4zkFPq75tL9Li4RndRfE3OvLzg4NehxpR 7BsNN0R5m0c9opAkJL6JlIjUUsOA1ykT/mXJOdQsyYR6fb57oiKtbNrIha3kJwZYPWOH wMIEYHPD28AGyAU6w4OI2LSttP6QdTuEGVHTFAyMPJZAUivDcKrs+jvzeaLm3icU0R1Z Qi4GmpHAfKV5bM1ms/Cgd65XA0WptqSBMqxm9pnzs/PwB78d78MG16jbG3t6cHQl+pSm Q5rpjSUNn50mLuPgeb+cTepNRgSLotWHNduSj6toBMx1gLpI/ZMKwFJosFb5otFC/nh4 FoRQ== 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=9t4c7iG7BwJixU6psOPlOQYO3J4oZ/NM5PDqz6Jeo04=; fh=NJLeKY2KYUT9W2cCzNpXoypltWWN9ZokmUKQLopfgqs=; b=auijrPdB1E9COJW1Sgvri7ZoJ47WGa/WoUWymu33/ZBNHBQjX13ghVl/CjaXuVOKso 3BKFITlBdP60RH29O5HR1EZNEXW9IizCKAkXb2S+VuQRV6aaQTjJY2WBiSL2UBt+AsqN DuD4ioeBSNKhICyYTZgpiUl/GER7HQh99pgctAvSSWOjHHuaFrDpCsD5cNDpwGRLAlK7 qu24op3PVCHJu+qPl0B7qURVK2k9ILQe0xAJH/w3LdtD8Yw8voLfadFWqR6uqaVuQhWr CYmV3SiEbG9XSESSponAWx4tczKWX+911DNCSuLikU8Y4N8IIsdNoPj/j+4U83GM8OQQ 1m8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=go7uig02; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bz20-20020a056a02061400b005740b47241csi4583583pgb.804.2023.09.15.19.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 19:27:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=go7uig02; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id DB6ED8076014; Fri, 15 Sep 2023 13:15:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237263AbjIOUPL (ORCPT <rfc822;realc9580@gmail.com> + 29 others); Fri, 15 Sep 2023 16:15:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237275AbjIOUOr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 15 Sep 2023 16:14:47 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69D4E272E for <linux-kernel@vger.kernel.org>; Fri, 15 Sep 2023 13:14:16 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bdf4752c3cso21264095ad.2 for <linux-kernel@vger.kernel.org>; Fri, 15 Sep 2023 13:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694808856; x=1695413656; 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=9t4c7iG7BwJixU6psOPlOQYO3J4oZ/NM5PDqz6Jeo04=; b=go7uig024KFWi6oiPZQJhAtrmKWw+a40kyRgE6l+AYy1c6LPcwO5JnM3tLeNxyeJ+8 cLLwmBYPVYf+t8uGQvT1sR1XwJOjD4Xlb8+DWaGn1hvnJ234lZoD+LqCu1/x3lVjz58J GBOP5YnicX8rgr+H8p9LvVMi5okOdkthYVq5Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694808856; x=1695413656; 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=9t4c7iG7BwJixU6psOPlOQYO3J4oZ/NM5PDqz6Jeo04=; b=BhZXmqoi1vIt8pi535DZLKMEJInk1EMyvqY09XjtDHAL0yAnDP3vR/w4nOn1a1X6mv HMPpNfPAoguhXeXYCniSWJ+ZGp8ZNvSNGoUxrLHoJitp1QMUjv8GFuWnyoLe4m7UuXHT ho4Hc2omucNXMfxsXxMAhGzltKJYgL0xRkNfGP+iz16g2X6HGPn0oYboEXMdihr+A9jV PtEk9OU3mydz/TTPYsGHSA0vs5qtZJtC0rjxT6g7J96VwzcSP2UA8v6/XZWtOVzRNdjK dWn7eliwESnCi7cjdESDszFK+CVmiJfanzyyi19kNyD+F3zmHVrlphFZeDO7KTMJuPrF fDMA== X-Gm-Message-State: AOJu0YxdBXqnwX4/XB7OlTyB+zImeJ9tf+x/WjPnr0bemBi4ka46OZyK aVVQ98EstuVmeKs5cI1xAj1e/g== X-Received: by 2002:a17:902:8691:b0:1c4:a16:f88f with SMTP id g17-20020a170902869100b001c40a16f88fmr2591006plo.36.1694808855939; Fri, 15 Sep 2023 13:14:15 -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 kg14-20020a170903060e00b001c41e1e9ca7sm3059479plb.215.2023.09.15.13.14.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:14:15 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Benjamin LaHaise <bcrl@kvack.org> Cc: Kees Cook <keescook@chromium.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, 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] aio: Annotate struct kioctx_table with __counted_by Date: Fri, 15 Sep 2023 13:14:14 -0700 Message-Id: <20230915201413.never.881-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1127; i=keescook@chromium.org; h=from:subject:message-id; bh=1qAoiZuMRAuvDZRUcSDPW5lLo0Ae9xZ4UiTXDEh1mTE=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBLsWaTUS2aPe9DYGUrDZPo05lmzAICnFfTNt4 TuHABaIVB+JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQS7FgAKCRCJcvTf3G3A JoNvD/wI9Ez/xecwMst1xwqWO5PzTIz1ZADRxzr2MoMrg+bF+zVBEO3uiWXoI4pY9farlKnMZOW F5S+SAgyURn2G3c6PN1WVEuc3Y9424hN2if8MTSVs0Nbk2EYZYm06r4Douy2vRy0YkSAWpssZ4v kymW916TdLMSRQ/VlhTwIqb/EogyHshGE7Zu0yDtUhDbfNo/bgJHm1Eb6BVnfWOYPkexC2wepRA /2J8yT+u4nZPjAW/UCwuRiP1zLd+xRXCtOQ9gm8mzijyKmqsRVlbzYa5UgI1Qr2byEv0P+KjR+K y6G/DhhriaqRy0FKJe0VObtQR56fWtLn/iUbIXW1qHAqKOVt3+/Xx/Qy+k6d9q+FucGZchog81Y 2br884EAL0MMUhCaLcwaFg4xWRh29AeG8bLDSSNwC9EIOIo6FlJdiPX8HsYfDRb2OkHYBrsCpUi suZXovmTwkZpy/XU8KHgnb7LmtJc2yZDea0oHJJbmJudfvmiUROsu2gT6uXwwCfFTZxacyfSznc ASqN8epE+clvMgEB/6HAUJXqXXb33j045MB2iUYymLfTnXHdblZnb/8GXLjn8Vs2KlOKemgOj3C lfmwn7j/b71qoQYPbLyXrt6loyYO6Zx7zzMnblLcq56S/LCrSIUYj5v7p70QXU/45+14jBKbzhy hj/G1EM dIHavvSg== 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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 15 Sep 2023 13:15:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777140197772578246 X-GMAIL-MSGID: 1777159388030498099 |
Series |
aio: Annotate struct kioctx_table with __counted_by
|
|
Commit Message
Kees Cook
Sept. 15, 2023, 8:14 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 kioctx_table.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: linux-aio@kvack.org
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
fs/aio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, 15 Sep 2023 13:14:14 -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 kioctx_table. > > [...] Applied to the vfs.misc branch of the vfs/vfs.git tree. Patches in the vfs.misc branch should appear in linux-next soon. Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it. It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated. Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch. tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.misc [1/1] aio: Annotate struct kioctx_table with __counted_by https://git.kernel.org/vfs/vfs/c/7f3782aef7e6
diff --git a/fs/aio.c b/fs/aio.c index a4c2a6bac72c..f8589caef9c1 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -80,7 +80,7 @@ struct aio_ring { struct kioctx_table { struct rcu_head rcu; unsigned nr; - struct kioctx __rcu *table[]; + struct kioctx __rcu *table[] __counted_by(nr); }; struct kioctx_cpu {