Message ID | 20230929180431.3005464-2-keescook@chromium.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp457154vqb; Thu, 5 Oct 2023 10:32:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFHHh1h02UnRKOoPYxTcuBdDcGl5P2VeAJwsFzD4myvMPFsLjtPmX/n7/fnPTRYSp2acjRJ X-Received: by 2002:a17:90b:4f8c:b0:26d:ae3:f6a6 with SMTP id qe12-20020a17090b4f8c00b0026d0ae3f6a6mr5230821pjb.18.1696527175291; Thu, 05 Oct 2023 10:32:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696527175; cv=none; d=google.com; s=arc-20160816; b=wDTsAkqxNJUdkv0vmN+6fjyI2wDF5ScklfO19bNpySeSAxD4dV7SMuhpEXy6aNLpve csHzzOIORqWygIvzaqV61fdaig/L1agfguDzY1Ix2x3TPoCTuqG0aJiiszGhDuRpolfv b/mpsZ8fNquaDAwG8sYwcW4kpIXngqusQtsO/Msd/humDYA0c8iI4Ff8mff4VNxIF6ai HdpUqteO3suEcZqVGZrojMzZSLndmfxis/S0E5pQor5kKQBs4gbV0t4yfzSjMnuKvVMM 04FRVKt5eMwBbGcFxvxwxUPJgc9rTFrck2paLBuOdkEG4CLOKmdqgAfXGABtIxHPQE0E XphA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vbdv0/nW296h6ChWMtIgFAyyvGlVNRpufvyfuyvShzQ=; fh=0rq+bYKOgei5dXRHaFXdtrirJdRHdzFdocw0uXvNWpI=; b=0WDcRtM4H7kRPsMLpBrOIqJqzYQvs49SkN4v86NlaHCiY+iUAnPpROQF36zpXHsS3B QIukiKf8CAxyUFo43hwww+X1HGi67No15cWGeORPXqRLzsfcqw3LTTXpyWWhtfsOwksf V9SmV5sz4ViixhAfvcfrPCItwKmHnEH9j3fzBRDS/PggXivmnF8ZKgaVJ4zumcqHg2Ee /cUnVKdzjeb+CzaMaW1rX/pl9VRBkD42JKZcOEe4chTseepYwXnYSFKBPkWt5X5lU0me 3WY5/MSp9lhBAX6O89wXhw/WdVXrnH9yR0784EHqWdaxW4phJXYOVtCpAv1wc/tyoScy bEDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IW5AVcAk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id me15-20020a17090b17cf00b002776909ee0esi2195601pjb.118.2023.10.05.10.32.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:32:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IW5AVcAk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 83C238339398; Fri, 29 Sep 2023 11:05:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233759AbjI2SF2 (ORCPT <rfc822;pwkd43@gmail.com> + 19 others); Fri, 29 Sep 2023 14:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233872AbjI2SFF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 29 Sep 2023 14:05:05 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D03CEC for <linux-kernel@vger.kernel.org>; Fri, 29 Sep 2023 11:04:35 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-690f7bf73ddso11479930b3a.2 for <linux-kernel@vger.kernel.org>; Fri, 29 Sep 2023 11:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696010674; x=1696615474; 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=vbdv0/nW296h6ChWMtIgFAyyvGlVNRpufvyfuyvShzQ=; b=IW5AVcAkiaAj4s7fJRndl3MMjtUWjDjxTQlKnjnaHjAjwt+vUsYxz9JgvlYoaK3M6f Ol9y9wATgMc/u+YmhVAdfTUrWxP1HZJ0oPNZltX2EtwlMLEg2h6mTN8CI/YTP0t0yyUe dD46nq7X5i+JeJMH2faLvf889/DSNBnZtgr6M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696010674; x=1696615474; 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=vbdv0/nW296h6ChWMtIgFAyyvGlVNRpufvyfuyvShzQ=; b=aM1emkDQa9hd2sO53wGTcxmtdIWrOEjPghZULgI4sUehr+UlzvK6HMcBjXc/d8in7S mX2V/I0yvJnfkrwshYSudLzpjEUskvAZtg6hySJ8XF0+vdeEEKjfnXkWum6sDDmPc7AX KNXRpAIWItCCvVO1lrMLLADSTiMspC1I+S3Tkp8tDAmA9zGHzzbWJt9dzYSlikkCeD5C XpnB6LA4DWjm/4Ke7GLLNbuPdBQtOhnJ+wQh9hn87yv7tPPw0hLgCP3lBhx0sCAj4Akp PGLz1uV6UyZzgudkNYmRO3CIeoAYvQpIfbSiY+joMx31Gejo0bvcwkSE86bUex1eMuZg BdSQ== X-Gm-Message-State: AOJu0YzfpIgHQgP//jdPLNJJ2igA3sHoJSHWa9YB9kJ05OeWkcPDtWsm KoVXMZgrY0Tshiua/iQhwXfttw== X-Received: by 2002:a05:6a20:6a23:b0:159:cf93:9b50 with SMTP id p35-20020a056a206a2300b00159cf939b50mr5241500pzk.46.1696010674631; Fri, 29 Sep 2023 11:04:34 -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 s2-20020a639242000000b0057825bd3448sm14577546pgn.51.2023.09.29.11.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 11:04:32 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Jason Gunthorpe <jgg@ziepe.ca> Cc: Kees Cook <keescook@chromium.org>, Leon Romanovsky <leon@kernel.org>, =?utf-8?q?H=C3=A5kon_Bugge?= <haakon.bugge@oracle.com>, Avihai Horon <avihaih@nvidia.com>, Anand Khoje <anand.a.khoje@oracle.com>, Mark Bloch <mbloch@nvidia.com>, linux-rdma@vger.kernel.org, Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>, Christian Benvenuti <benve@cisco.com>, Nelson Escobar <neescoba@cisco.com>, Bernard Metzler <bmt@zurich.ibm.com>, Bart Van Assche <bvanassche@acm.org>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, Patrisious Haddad <phaddad@nvidia.com>, Chuck Lever <chuck.lever@oracle.com>, Tom Talpey <tom@talpey.com>, wangjianli <wangjianli@cdjrlc.com>, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH 2/7] RDMA/core: Annotate struct ib_pkey_cache with __counted_by Date: Fri, 29 Sep 2023 11:04:25 -0700 Message-Id: <20230929180431.3005464-2-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929180305.work.590-kees@kernel.org> References: <20230929180305.work.590-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1301; i=keescook@chromium.org; h=from:subject; bh=8qTIqTpqch+dyj739sghT5yZ5j+JjtWjxI1TdxYuFP8=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlFxGtnlN5Fv7CxLg4EAHhoDTEkyA2uohAKbEuJ GpqdYgLKF6JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZRcRrQAKCRCJcvTf3G3A JsP9EAC0DgrjiUKiy5qvIIyWJvdycEGXOMygwychR18Ef+pgg5+zSsDS92qrEYrYtFz76UNEjXu 17JwoDffv1yCBXGPdCC533oDBSgVr+TlqtP2MZGJpAFB2jDA29+Dh4hzGUwpMr/6MnWn0bTR+Vf CpNLYII3OIAvmJ7tmaGaoHilX1gORNFvw6QXwwBjPqGo4OVFa8kBf1B0rtFRYcv3mAjY6/NICJX SHYsUU4Ics30sqUiukI13sfP3+hBHWUsXPfxlfPua60GazyoI3Knfr67AHenGUpiY+IW4aLoKdS o2kCcBAN7fkiUfZ1gZ78iamlNXXX0OSwijoe8XxuBtjfZazk6bZ+fvQocUBNAtcWA1GpKYkmzuD WZM7ZiZAb+AikXlQapk0bMLGL+lDIHr8vZDe4wCguY0+c2vj7sF53jCbCxvyHROPFaIf6NOF8Sl WgTV/v+kMTa9AYlUC/XwuF6+IkQA9oAN3SwwYjVJ8fIpCpFEr2BsgBBh3Ga0GVx1N+voyDpWY3G F+h9MTIiqcG9+eMOkNDRxa/356g84qJQVkHabmIondLkPx4Fhxi4sl0Q/z0lMrXCKQWUEiD0CZ+ EyY/I2qS70/lsYtItOwfyhWLxUvHwRLNmkGx3T7/t7+KYvzbr3n9McTs1R8tzNlYTWrKwQ52ImD 13o2YAgRaZPedeg== 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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 29 Sep 2023 11:05:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778937679726535165 X-GMAIL-MSGID: 1778937679726535165 |
Series |
RDMA: Annotate structs with __counted_by
|
|
Commit Message
Kees Cook
Sept. 29, 2023, 6:04 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 ib_pkey_cache.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: "HÃ¥kon Bugge" <haakon.bugge@oracle.com>
Cc: Avihai Horon <avihaih@nvidia.com>
Cc: Anand Khoje <anand.a.khoje@oracle.com>
Cc: Mark Bloch <mbloch@nvidia.com>
Cc: linux-rdma@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/infiniband/core/cache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 7acc0f936dad..c02a96d3572a 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -46,7 +46,7 @@ struct ib_pkey_cache { int table_len; - u16 table[]; + u16 table[] __counted_by(table_len); }; struct ib_update_work {