Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp3031641rdb; Fri, 22 Sep 2023 16:17:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGt+ez1PsW0DOFRs2zPbhWpu/7cCqDWJfpvuPqQQNj8eN5a+1coubCA3ZIRYnpsOciy+9iU X-Received: by 2002:a05:6a00:a01:b0:690:1720:aa92 with SMTP id p1-20020a056a000a0100b006901720aa92mr946309pfh.10.1695424640882; Fri, 22 Sep 2023 16:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695424640; cv=none; d=google.com; s=arc-20160816; b=sfPWE8+TvGawMab+LWbvoR2Pd81CYNvVunW9tshpqXQDOItjYCzcouIdvo7FC71pbq maIEC78k4oUkq/ZwD3PzfgkatnhS319psqvtOEzZXW2PcecpkVX/E7ptkfYG+iEyO3dm j3SMZ2yrk7zebb6yixx8oeQT8NZDhQgG7wLJ3J6nCqYg2czf2xq4usBofAcOrwsj/hSE RKZ8dBceJhQhHNq6DKbUWpSTMNtEpOQEsrcjqxWdxBg9uWwCuGfWL9ep/C8ZOJ5U8rzk KuJHYCEsGO3gKL0HPgFAupqvt11Ew5WxsBOymvOhZ1SM0OCmL09/lbz66V1W5rTU934+ NOMA== 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=P4lFdFSF/WMtJZ1n0IFqHz6mtLvevkit742tpw5OZis=; fh=IwQooJ5369pDliOH5m4NidRKm132Pq8x6wW8H1eqjdE=; b=NMB1TfwoXo5Q4y5aDq/i+rwou62RV73KbzRnBUZxKQHQGzw802PocleOSVm+6jDXtX t3ppsLaSIbQJh31c0swsl+QRcqgzaY0AsVdoJwZ9V7TJu/uq20+UfPXhp3k5CD6Gid// CisCbMKF1rvvkml9sAh0R8NyoVZ/E55ImuwVktNhd728SWQTuz3n9knVShnA/HcS4h9V W+WQ+QBELLfRsg2J3YM77Moe0C2jvrf9HQ39fe9SbjJFe28vADpA/oYMctHCPEWVDNF8 /engK70lrefiDlYiwGOinHT5P35c3oiMs1lO0plpFjLAMBLgA2+rTa7bnLNfb+81drZv elhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TUltBHeC; 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 Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id k126-20020a632484000000b00578c64433cdsi4650120pgk.895.2023.09.22.16.17.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 16:17:20 -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=TUltBHeC; 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 C307C8379A69; Fri, 22 Sep 2023 10:53:47 -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 S232924AbjIVRxm (ORCPT + 99 others); Fri, 22 Sep 2023 13:53:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233419AbjIVRxV (ORCPT ); Fri, 22 Sep 2023 13:53:21 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AEC710C7 for ; Fri, 22 Sep 2023 10:52:13 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c3bd829b86so21835025ad.0 for ; Fri, 22 Sep 2023 10:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695405133; x=1696009933; 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=P4lFdFSF/WMtJZ1n0IFqHz6mtLvevkit742tpw5OZis=; b=TUltBHeCRYJUzVo8fVnGboc37KWD2XGgCL6pMasy80W4bhqo4tBxLiHWPwkomfGOnn p2S3UeiOUOaoK14y2ATMxh1h/eRsSjtcpz4zOEGZTi58msCxUxAQ38qVJB19e7bHofgx HKvV/9RB7HLpB+ilyMejoIoCHrdxcIllBq1ak= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695405133; x=1696009933; 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=P4lFdFSF/WMtJZ1n0IFqHz6mtLvevkit742tpw5OZis=; b=hG+EVquNp3EVhZbzR3VH7AF9T4cB33BBoMfATAyvY48CcBzbsqy3hcVs5Me3UFhk06 qG/0CczMGhIkl/4ynzCSIByDmbJeV1eWw+e2M2HG70T083kzpUK13yJffnvRENGe14rK hLEZEZGNZ15MdFPt2vuQDRKZiFuxjRAhLaWycb+6IrNRDAtA/Fpq+P30dWx1hc3wIiv6 qG4gL0bfIthY7L5ybRYdPajfKTv7a5i67AvQ0+gbZynuexZLwPH2SELwj98l3lHon7iA fZ+ysTgiEFGF/De4GaqJR+Yknk3xbNYbYDONHcYlBrsSmtXADNFuyQttF1PQq2PS5vMq z5Zg== X-Gm-Message-State: AOJu0YyBnlav0Y1/Qj3+IhrLkv5jPlnSNSLKrRp22iYMFD2UM4R9qWBI ms69dW3W+ENlEC9TDo9UAIhfWg== X-Received: by 2002:a17:902:a407:b0:1c0:aa07:1792 with SMTP id p7-20020a170902a40700b001c0aa071792mr169699plq.36.1695405132793; Fri, 22 Sep 2023 10:52:12 -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 w12-20020a170902e88c00b001c5b8087fe5sm3784878plg.94.2023.09.22.10.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:52:12 -0700 (PDT) From: Kees Cook To: Damien Le Moal Cc: Kees Cook , linux-ide@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] libata: Annotate struct ata_cpr_log with __counted_by Date: Fri, 22 Sep 2023 10:52:11 -0700 Message-Id: <20230922175210.work.239-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1046; i=keescook@chromium.org; h=from:subject:message-id; bh=ei96zfUMfrVFB3I3JdJNLz4izHCeTaYCT55cR6z67TQ=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDdRLFoAwT1mCQLgtm1SMCJS/1dZx+seXgkUyx yYvrZTRLmuJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3USwAKCRCJcvTf3G3A Jm/NEACCMtnhoEgknOC6Ec69yaNMsjXyzdjGfPY/uDjWB8+n6l4ZY/abY54yTq6xlFNSbERWzy8 tTgTWRYZDHWLWFGja0Ov7FyVjLOC4LQcdhbsOu31k8bck/BANRCs2UHtkK5AVLxBnVqZ1zDWQNa W2CdnFimXRaOo8wIg4eyi2gKj4pA95HuBP8w4WIzCkuucorP7rfyu5lPvE1/SmwfIf6j89Q2W82 suLkFQycstU6zebJDhPSs+V0gswuVmna0ifYiKJ+CnBVqQE4Vct/HJKGFxycica7769JXfk3DCX /c/MwvwlYinM8lTmzRUjbZVCfPx/mMO4MmSmmIUpl5+BELtQqZ+2TaP8tbJ8gmbLoy4uqx44huH +ks/vzrsMA2RdTm4+mZ+qekAIBc7wlp8EG+heSZ7BqKhgulEnhWg0wuKGID2fo5MlQw8+Ax4Vu7 uxlfbml1ExdKOuuFoD5Iwi8jbQEJYM8fpdArxCmQPCa8MMJ3J9HuCmmX6dtQqQQMS4J9kvDaiTx VQVH4SdBkWJTgt96MILMcCvQNVZLXqimqbWvXGQQ1C7QX+CtwPZiOSI/wteKNiWnSUwc2iMLKFB p45aN0buN27a4uTP2QaKsutqZT1vM/vbj7jSDTlcmLITJjEBl1uMh8SVnPLEYHnfOJvkWs4kjiZ 0d4Giey 7//WndUQ== 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,URIBL_BLOCKED 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: 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, 22 Sep 2023 10:53:47 -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 ata_cpr_log. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Damien Le Moal Cc: linux-ide@vger.kernel.org Signed-off-by: Kees Cook --- include/linux/libata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/libata.h b/include/linux/libata.h index 3c17a5053f00..f91e8e7f1c00 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -656,7 +656,7 @@ struct ata_cpr { struct ata_cpr_log { u8 nr_cpr; - struct ata_cpr cpr[]; + struct ata_cpr cpr[] __counted_by(nr_cpr); }; struct ata_device { -- 2.34.1