Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4925110rdb; Fri, 15 Sep 2023 17:34:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgc5GFo1XAjt2QBr8ElHW+m9OHX5/cJGJK2tOxd6BOd3eRUdq/tZCIRQwj6jEofF5vJGgS X-Received: by 2002:a05:6a00:2315:b0:68f:a5ff:3f3a with SMTP id h21-20020a056a00231500b0068fa5ff3f3amr3416938pfh.11.1694824457013; Fri, 15 Sep 2023 17:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694824456; cv=none; d=google.com; s=arc-20160816; b=PMfUtqm5UNYUno/H9acUgGEH2r8Ef8uaa9umZQ9499Q9UMfzkKNecUndhmblhfd+r6 FM/kiRERSkA60HMZF1cNsG5uzoMPZeb+atz2JP6yCuptUciPQbq0oO2eUf8BzXns371d G/YtN5NHxUj8kVRkNg5lr1I0HWu15ADbx5uR7cqS25d6ofV7zzyUbhR46BHvOp403lL4 wkW/Ut9+aMKYfpQk+G6o4drEk7Al2/1NzrcTkXE2+Q5rQyB/Jb0FSC2npkKR0hlwSMoh x3YiZ3Povbjip0791rmd8/FiibsYBS03NTIhsdXySax/Lxae992CzcPAyqOOgIsTF3fH dpZQ== 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=n0Hengu6K84ftLWMR961tNpe8ygiAngUSieA27Tmw8o=; fh=NfeqyPNXPJ5LjwzX+OQWTMERxbS3gKTIX3ply9ePdrI=; b=Sy/saQbIO4m/88qCuQrPl5nNO1Zzx2pdXIlxqrKD7ujeUi+gt6f8gjto1BAdb0JqIt QV6UO27svI4FkZTqxBjOhnGMj7PcJ06d2reY6qN0/CX/iZMWLTRKJoh1A10zqg2ScImG ur2Q0cy1372p+zE5qGxcHNMT0iIlLoVv8N1ogasJ2LHWv+TBto3HzSJjWom6f7Gnl3zT GguFvcpW7lG2+nSrNQ+CpXVp6CDkg+y3Gi9vTyIf3qWJa0SubhJua0xQ4T4VFvMMU9Lh JlxqTZIu1uZk5X/9iW7XnDVxPsvWoFhWtmLpiQtZc82Zc0I/WG6z1bKlCrORr2t+n0By LEzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mTjofa0W; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id f20-20020a056a0022d400b0068a68d71b68si4124579pfj.216.2023.09.15.17.34.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 17:34:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mTjofa0W; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-wireless-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 6D4428368AA6; Fri, 15 Sep 2023 13:07:38 -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 S237158AbjIOUHI (ORCPT + 57 others); Fri, 15 Sep 2023 16:07:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237189AbjIOUGq (ORCPT ); Fri, 15 Sep 2023 16:06:46 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 097AB2D6D for ; Fri, 15 Sep 2023 13:05:55 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1c364fb8a4cso23478115ad.1 for ; Fri, 15 Sep 2023 13:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694808354; x=1695413154; 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=n0Hengu6K84ftLWMR961tNpe8ygiAngUSieA27Tmw8o=; b=mTjofa0WWeMwSESHvEFPRZkSP8Ukosg8qDpGwK3km7Yy3O/LY0Mn8iuGPbwmE74reh kNstE0TluSB/7eU1th5eB4f1KugMlV3c9MVYincmV0APD2yU6wUtATpQ1ucIr/wrJ++R RuyGUqprZY3Voe1hgkbOAizgJ2/D6R9Y6MwBI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694808354; x=1695413154; 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=n0Hengu6K84ftLWMR961tNpe8ygiAngUSieA27Tmw8o=; b=R+e79LKouRTqTEzuNPCTVyBg8ES9uqlBIrbifSvoOpMoFc+2yVqvC5hB1vxsD2UkBU z77jMkVwtSr2GAkR7MN9TfiptzzAXgbtTa7BeJG4s1TjqLDvUi/Qb36taGsXFSswbCXU mYX1KsY1ylfHgENnqbsErSupTBh860XqCD7ZKP1/Ck8KBN9fpl13kCSQiYTb59UvYV9N E3u7keKb9vOrVNx1p0fbVAkYi8ddIehTAUbjl0ceXVHBpbD+TkhaxWJo7TixBZzUqDq2 eOfgt+NZ69k4E3nY/At4AUV0qLsxBNLdnKgTHMp+PFUiSDV6mdstV/Lq8buCF8s8Wb2O 4gzA== X-Gm-Message-State: AOJu0YxgYDC7QTmsrS9zo9VKsPb/61zt9gHTaqp+zf3/RYo3JJ/6BOjR ateuvktiRfpeeZJzfdyHNjLdiw== X-Received: by 2002:a17:902:eccd:b0:1c0:ceab:e9bd with SMTP id a13-20020a170902eccd00b001c0ceabe9bdmr2471233plh.25.1694808354539; Fri, 15 Sep 2023 13:05:54 -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 j12-20020a170902c3cc00b001b9e9edbf43sm3884947plj.171.2023.09.15.13.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:05:54 -0700 (PDT) From: Kees Cook To: Arend van Spriel Cc: Kees Cook , Franky Lin , Hante Meuleman , Kalle Valo , Matthias Brugger , Hector Martin , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , 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 , "Russell King (Oracle)" , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] wifi: brcmfmac: firmware: Annotate struct brcmf_fw_request with __counted_by Date: Fri, 15 Sep 2023 13:05:52 -0700 Message-Id: <20230915200552.never.642-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1682; i=keescook@chromium.org; h=from:subject:message-id; bh=weqFhcMmCNEK0MsxB/YQXMpH/1sEF3VWxqr/sIkwvFs=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBLkgJxO209fAiikOP4NOLZvvkl0taCniJgeTe BfOIErtc2+JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQS5IAAKCRCJcvTf3G3A JuUUEACZ2zaEA8T4Cn+MXQTZsiQW6ccYb+T67EABtpHMJ4cpCBYnDUFObSJdhqyNgTMRDPYL07d 6fCfLAJQEBKhzzlKriudyRK7RKpMLFXL1/VZ2VshpPpr1+nih8BvG6G95958M/2KzzNfBnJW1K2 r8ll18pOYxr53JHtE0afMIbVijjDcCmJ1YBnSdSWF4F0qdJSLYxI7tWXmOcanyNTMgVktHRikWK lvUS2q72eqNEAM8NTOBfg8watlPpbDk7Dvooq+jYCZe5qCV7FFQOohK4NFaje1Y/AbRCAYw6ItN saFM0iOJNyUWDpt0hsG710nZFYvpoGsFkhHBbzqFoySbVFfqhQD5ubDa48yoN0AD0hWntF5IJrk VUiGrKP8rXAHmTO0gqMAKbjlDJr2pZez8QZtkVa2K7hgHpabCN7d60rbWvAyjMaba+QZaMY1oBB 7tHL/Avo/6NdspsNpPVeiFpRU3mDEhjiB6i7fJqblMFndNBs5gywqAYyLtbmMqGKijzhbW3qC+j JYb4HUVvToJO7FD3EzJMQQjuNcxjoc5CmlwNJxMYW1gfIwr/Fv/vSnFOMzB9R0yV8fh2xUHjGeD sEHOO1E+G+Le0NLFJBX6tKqb451jPjxpTyT3+IpcOopCKnL60hv8UlEjI2U93m+xzsWhbrL2F94 WI39utA MSfdKWew== 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: X-Mailing-List: linux-wireless@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:07:38 -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 brcmf_fw_request. [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: Matthias Brugger Cc: Hector Martin Cc: "Alvin Šipraga" 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/firmware.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h index 1266cbaee072..4002d326fd21 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h @@ -69,7 +69,7 @@ struct brcmf_fw_request { u16 bus_nr; u32 n_items; const char *board_types[BRCMF_FW_MAX_BOARD_TYPES]; - struct brcmf_fw_item items[]; + struct brcmf_fw_item items[] __counted_by(n_items); }; struct brcmf_fw_name { -- 2.34.1