From patchwork Fri Sep 15 20:05:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 140937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1475861vqi; Fri, 15 Sep 2023 21:42:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHq1der79bS0SdSrUcjN0TCzc1arvGQ+0QqxKGc5gCZzE7pygojdpROKPDEpMJZ7FhgxEXC X-Received: by 2002:a05:6358:726:b0:135:57d0:d173 with SMTP id e38-20020a056358072600b0013557d0d173mr4494247rwj.20.1694839353405; Fri, 15 Sep 2023 21:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694839353; cv=none; d=google.com; s=arc-20160816; b=Dwp4Ftt5NcvFSdjTKvdbRo8XVMXl79gHEeFd9hr5jivfE+NMRbpxWaAALA0NjqSZJM RJodR6OuLVCEvfK0P8FlYXLL2SL2jPPHchPx9O9h7gLk/TNJOIUykr57kmeylGuEBY4A 6f3t/2/02r3oZXynLTeRA9nFKT7whdvDB9xjxm8gfyrLev2rKpFku4JhRBpLbTJkYnzx 1TI2AMpiihfP/kNXQQnZQS8slCIRurVhSkB1p1ylAAbE7CQAYN62MjnesoPChVgRb31L j0oDU6c+lJ2gwgPnnxoZ2H63uqPH0sEPYfCJwAXnMikHHsHMU1zgLQ0yx+OBEF0GTUdU kcXQ== 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=aR/iTkKbSTclF/9WdaJ898o9CruV7+egFFYPhFiTMFM=; fh=Qh6TrxeOyoJKQDcCmtbnu4R0O7kSAj1jLQN7bZ59rvY=; b=Vf8Fj//0jQD3Ga9liZpDjsIUhktoq2hG4zYq80nFPn7IpP8AKXjRF6EgPjlYmzZsNN OHR0FhYCMPRzTIHpZRXzb0OiYJRGvWsI/dRpzKcQerMOJKLLSd+rrGrnCm6M+wz0VToS JLUyeMLfTXU2QCHuPvEcnVznEzGLEr/dMelng4dM04uM2MkR8CeWu8KdGzzMalL4Kjgb eP9wA8pJakA1G8FEmG7QmKJO+P2AE2wmLNt9aM5VTaGSONHZeeyUFN6aG+1Tdvrog23d ABcwjp/Sr4h0Ac2tOI2hbvm5XCgeKztCKraefJq8yzze7cBll4pGZjIEzu6iUvpSlwjj DSNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gvE10czI; 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 bu15-20020a63294f000000b00574166b7d34si4284707pgb.881.2023.09.15.21.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 21:42:33 -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=gvE10czI; 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 D4A3982251D8; Fri, 15 Sep 2023 13:07:41 -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 S237189AbjIOUHK (ORCPT + 29 others); Fri, 15 Sep 2023 16:07:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237167AbjIOUGk (ORCPT ); Fri, 15 Sep 2023 16:06:40 -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 F37542D62 for ; Fri, 15 Sep 2023 13:05:45 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68fb85afef4so2464036b3a.1 for ; Fri, 15 Sep 2023 13:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694808345; x=1695413145; 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=aR/iTkKbSTclF/9WdaJ898o9CruV7+egFFYPhFiTMFM=; b=gvE10czIM9ByiLJOmSDTl3YUa30w7UJ22m/5Zza04SqWhJf8qy0hcG4ruP32iD8Wq5 mNptVI4hKJjBuT7PZEJbHDtrGUiUAl1wPtRPzytUizdLJ5kv+mO2tgco8S8q3Mm4olxO znPLBtx2bx/XZNJumXUMNSMNrKteIPmei3j+c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694808345; x=1695413145; 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=aR/iTkKbSTclF/9WdaJ898o9CruV7+egFFYPhFiTMFM=; b=ojZ1vax4cifc7GtaR8ZewzBkyM/ETYr0UZWeYk6zIe9MBEbFZAepnin6MaOjEmNJti PoLCg/R6iWP0qEuGYf7ZfEKEiBensjCAw9FTcpNae23JB1OECeQjVndqlC6qVsrsB1ZZ nc3FWOPmQHr8UPdgPvXfLv4aLy2QwxYT8ouEIsIqhRQCkE9l4W76b61gs1PvFmrXyQwb Cu86DcXc05Dv7+jwu30ugUu3Xyxg/QtJoI+D3EnwilMj3DILpS8LFJe+f5PkJl+cKWM9 fJnghefcoG6X6dVuiPvMq17N4kMkWh5JmW90ZWBC4jA84lUdidl4M+1vvphqMADpDzCY xfRg== X-Gm-Message-State: AOJu0YzyO2tnpBlAC5uppVpCsd935TeiuOs0C9nQQd0MbzyWQxoRPthb DADDDnUMSPxQpeBiNcQHGxb4kQ== X-Received: by 2002:a05:6a20:1608:b0:159:c918:1016 with SMTP id l8-20020a056a20160800b00159c9181016mr3227733pzj.49.1694808345500; Fri, 15 Sep 2023 13:05:45 -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 m30-20020a63711e000000b00573db18bca2sm3132905pgc.33.2023.09.15.13.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:05:44 -0700 (PDT) From: Kees Cook To: Arend van Spriel Cc: Kees Cook , Franky Lin , Hante Meuleman , Kalle Valo , "Gustavo A. R. Silva" , Hector Martin , Ryohei Kondo , Hans de Goede , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, Nathan Chancellor , Nick Desaulniers , Tom Rix , Linus Walleij , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] wifi: brcmfmac: Annotate struct brcmf_gscan_config with __counted_by Date: Fri, 15 Sep 2023 13:05:43 -0700 Message-Id: <20230915200542.never.417-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1730; i=keescook@chromium.org; h=from:subject:message-id; bh=X4WmyrGHDGI0lmYXa9tAqxY62elCP40zpnliUt752qk=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBLkWpwM2ImPrvmH3OQf9Pk/Lq94hutLw0lb0x lB0vtONpvuJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQS5FgAKCRCJcvTf3G3A Jq9tD/4knDbJaYtMtmuYbl+odY+xjGbWr7tfc54DKzFfAwSZYR6unzGPjAzlJBE7cQE4ZO8Vbtl JUU4R+2Qg0vz23t2n+W028mcnONszI6s/3g9oYHuVegLZWU16CPk1j81mijiKzwn9RA7Ogbf6RL laxCscdtdC0J/iOedBEHdrXlf0nB4pVhCwuwuIWhyp8nLTx9jsrSHVft0uiBD7NdUt9PR4M6miY tQzXpXWfCMpsXR89UnT/FfFh4W82tpEKqnFrJavIrJNwbRPEnmM4z4J6mT/QNu1GVqidKJlL7wE e5OSd7C5rHWBwZlSRe3z7L+hTLT8kgLSkXG98yxVC5GQigByn34AEuQC4oneqZpZngynNc/YRiF HcS0QAMnmk4jdmeft8ebAE8kuT+7cbkSSn059qlldfKHmZ8XSzQZRqAADPFHPP5TxGr/lCJAbrW 2QQAfO4VbyApM1J/yqpjZ39cz0o9/b0AMi7Ymynfl4cjCo3qdpU/u3Te6MvDSUiNEfkoNkY/xq0 6/TYWQSmE1SQ0dKAZeu7Nm0PUlUTKkCb51Ui5oKCctV1X5noukQJc8IIFihqllWQEUm41RP+4VU EUEtOI+5Zhzud+k6ldz8ExSqDFfyMBxm6EZwNl7J8VgUvfyTPLsITFGcEZaCCX9OG4WKwkHISwv YwOYvhG lChfhSQw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 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: 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:07:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777137201898057971 X-GMAIL-MSGID: 1777167870143491647 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 brcmf_gscan_config. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Arend van Spriel Cc: Franky Lin Cc: Hante Meuleman Cc: Kalle Valo Cc: "Gustavo A. R. Silva" Cc: Hector Martin Cc: Ryohei Kondo Cc: Hans de Goede Cc: linux-wireless@vger.kernel.org Cc: brcm80211-dev-list.pdl@broadcom.com Cc: SHA-cyfmac-dev-list@infineon.com Signed-off-by: Kees Cook --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h index bece26741d3a..6eef6bc430e2 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h @@ -1209,7 +1209,7 @@ struct brcmf_gscan_config { u8 count_of_channel_buckets; u8 retry_threshold; __le16 lost_ap_window; - struct brcmf_gscan_bucket_config bucket[]; + struct brcmf_gscan_bucket_config bucket[] __counted_by(count_of_channel_buckets); }; /**