From patchwork Fri Sep 15 20:05:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 140724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1348182vqi; Fri, 15 Sep 2023 15:10:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFp3VCqtpnnLlQ7IHkYBGbfqWEqQzQ3O6NeRkvxlQWXMOUwV962qyvVUveAwYI9uMjymJP3 X-Received: by 2002:a17:90b:353:b0:274:1d71:198c with SMTP id fh19-20020a17090b035300b002741d71198cmr2732409pjb.14.1694815854636; Fri, 15 Sep 2023 15:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694815854; cv=none; d=google.com; s=arc-20160816; b=sJ5RW2Mhft6N9gdQBrwyXCBr6Ih/eQl8VTJXa2E3hpwzgApx99PLn9g8a7wQY8HgVN CsMWXBibKY+NlkpEjDyMVKc79q1GQHNpqmbvOLcRGFHc38qBpsepL6Wd7Zp1EEQagds6 3dignmBV+dYUoTXo+3ewYDoNqyoC1Rq2GIQ77eFd8co+EUXL2gVNckJcxyI/OnmliDgx PFI6aiGgFO95QQva6RSsa8zpH7bIV7wvrvU80Ma+c22coqerCoSi3RCGsaoUbtr6z54S 8ABx3vMicYnewgycoZ0X4YV5qpxa62F999vHdJQpqMPh+hr7gCpd+4kOLLxfpX/TvQkm aaKg== 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=g09NXLjeQWIqFLA1gpqNnsIqOPAVxsFLyahy6uHnhwB7e0+pFff8twVvRZdidXT6H6 b6JGYZtYgFv00fEG2l3m9X3isX668wcLra2ECNiJal1kwp77RYaQnzjLX6E8ZcsFO2YX cFEfXrXJ7JchnSrjjnLYpG1oFhHNgbRwGoVWSmFcSRhP5F8zVwTcBog4xMf2prBdH6QV Tt5Xn0lIEaptKJbuZPjTchwrKGIjLkY7TuW4jQUQ9I/5Mf4DZ+5NTGS5uemo35n6Aw6y nYNu+FBkG0b9VYcmaUdDDqb7q7mYejbDwSGN780zgEl3iaRqRo5CxT6o7vjsDqVggvX0 Ttkw== 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-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 a9-20020a17090ad80900b002683f507990si6139044pjv.109.2023.09.15.15.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 15:10:54 -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=mTjofa0W; 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 A8AA783C539D; Fri, 15 Sep 2023 13:07:46 -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 S237228AbjIOUHM (ORCPT + 29 others); Fri, 15 Sep 2023 16:07:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237185AbjIOUGq (ORCPT ); Fri, 15 Sep 2023 16:06:46 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 096032720 for ; Fri, 15 Sep 2023 13:05:55 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c337aeefbdso23509915ad.0 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=H7DjfHF5UDFomRG2Ocj3S0wYpLxsRzERelgLlEJhSBQr6G4tdWbGxSOsGViJUdQJ5G d3yw69ONXSPe1+FMSZ4SOuDg5ONqM/p4oLh9BBF6xOk+9/1on2F02hj2+VqS9vDATL7y GlfaANIxE1hcbnYhnBuBzs0wkVMIyy4pA/SeQ7eTeuDuCWbh+IOGKRWTYgybBx0wUjYH FTbFngDwfGRRdMbDGmBWxgXsiy42uAel9hG60Zhr4K/3QXA1eCERGErfICuyidExnUjO 0vjLsflyNIXo5dpuLQa1omjt7DoFzj2vBxe2UQGvZ8bVlxCXejPXEhlmwomzIS/L2g2j IMbA== X-Gm-Message-State: AOJu0Yxwe82le7Vvf6TUO6l00fMnUmxm0C3Iv+qu2djXffjuztZUG7As OUkGYoSjuiuhkOCMoTKTL4WnyQ== 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_=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 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 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: 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, 15 Sep 2023 13:07:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777143229655908142 X-GMAIL-MSGID: 1777143229655908142 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 Reviewed-by: Gustavo A. R. Silva Reviewed-by: Matthias Brugger --- 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 {