Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4928914rdb; Fri, 15 Sep 2023 17:46:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IED17RAv7TJ0zfQlMhTEY4BItCehxdfo8rmcx1XLG2DCx822Z15yFSwmPqrK/xbM0eWWM3K X-Received: by 2002:a05:6358:24a6:b0:134:e4fe:e162 with SMTP id m38-20020a05635824a600b00134e4fee162mr3925260rwc.13.1694825197686; Fri, 15 Sep 2023 17:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694825197; cv=none; d=google.com; s=arc-20160816; b=ZMP+l5M90U9NG4NlWv5dO5Sk5AkCq9pwsLrBAWW7e3U1LRkTuXQADIZclV44dPKJlV KCDPmoaBwhUIT24rvSjHt3MxPUy3tap9rDCO6yhX1Znw1QwPXxjZ+cdiEJ8FMhXtIQBM 3hQb19fqDM6WECnPSSo5UKhp3XfvvmpHKRIIjxmsHwGhbsQP+CyJI9Zv/xDUovX5cZvd mL0uaTulkz4lJdG42cVCg5tGIHglDRtKdpOhbWtGH/Dn7hNliJpu7nnrN82YMka1NHMR Kp0Dz0xbwdxhHh2VM4VirpIk/gBozCMUAiiCQj8NbUFtFutvp8c3ANVWnofdyshw8pKG 5+Kg== 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=dB1pwLSw3TfsJDfFAPemy9b5TtNPX4UXkiSYwc3PxLw=; fh=EaA5sEgHG5cPorsPIYmVuiew9MuOc2QBv+ywhjgiWeo=; b=vEugXj6XtlZH7snutFVa0yt0X69Y9Epq5KQtpVrax+hQZwh3s9BVlIpRZOYEyu2bjp kkGG/QlsmWLnKPYmlIbi6QuyGtoTpOZIx41+5ch2uP58w695re++dUseh4iwccRFd7ET vNljjAH4GW0MtI2QPZfkbFyPEUpOXU7lGS+rlq0i3/x3IpDOe43JTysy+sFy4KsZM1Fs 1CdpPklBFK74nQhJ46oVOPU/SW6CjSsaxrOjLaftp9YBl3hNVleehGXSMovUkXriIjFz 8PMNq6oDx814htzNJMUulkqvIkTfWuSuFOZQupcz7HiboIdIbL8cUoYPosmPzFRyr6eH /q6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=j6TqJJdl; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id bk13-20020a056a02028d00b00565660b78d3si3896372pgb.591.2023.09.15.17.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 17:46:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=j6TqJJdl; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 71C4680B028A; Fri, 15 Sep 2023 13:07:42 -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 S237128AbjIOUHH (ORCPT + 57 others); Fri, 15 Sep 2023 16:07:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237260AbjIOUHB (ORCPT ); Fri, 15 Sep 2023 16:07:01 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96F73273C for ; Fri, 15 Sep 2023 13:06:29 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c3f97f2239so22146945ad.0 for ; Fri, 15 Sep 2023 13:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694808389; x=1695413189; 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=dB1pwLSw3TfsJDfFAPemy9b5TtNPX4UXkiSYwc3PxLw=; b=j6TqJJdlR2DW/SYrp7PPvx3W7j1C+SV0WzE/ji76VnUlPlwTCuzFeRDvtlzOB24Vgl XwdTT24f6aK2+sby0LpgXYyYVxWaXIH5o7gCqBgK4hKit/wKZtufvy9dI0SFdrEgX2pa kVIA00KXA9JvJnIbKd+bAlVGlzTI0E+UMpJEA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694808389; x=1695413189; 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=dB1pwLSw3TfsJDfFAPemy9b5TtNPX4UXkiSYwc3PxLw=; b=VYTyoI8/6KsknTRXKwqBPS7J1f09ezOs+6/YlaD/0cvT8MUtlJB1GByRkfRSr6BNko EnVB05cDGnEip0tTZM4WWdWWeVYfPrtrA3erhUhOsui7iNwqzpLrRivETUIh4WfWCHar YuH58I0WdLBhHFq9YRB4ofLt02SxWQkibp5jQ4qdI8RsiIZz6PWRmk8H6C1HAgvuAvFT JVTkjy6z6GnN13BQwSmCvX5T2yuHzyxW2aJbicR1TcScoet9TW9EtV6HiXO6foI1FtD4 rywiRzawGJzmrz9CnATRUL87yY3w+desqUFz9eZzxKvGEuq3gW6Rpx6EkCAcsVNT7/sO ZK/w== X-Gm-Message-State: AOJu0YwmuEe14fnds0EM16qe5nxeXozj0CoRXi648ZVICm0iE0HhYS7V SDFR6lwuBj4Gc+wh7pGD65IdaQ== X-Received: by 2002:a17:902:c94c:b0:1c3:cee1:cc8e with SMTP id i12-20020a170902c94c00b001c3cee1cc8emr2842576pla.68.1694808389168; Fri, 15 Sep 2023 13:06:29 -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 b7-20020a170902d50700b001a80ad9c599sm3857764plg.294.2023.09.15.13.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:06:28 -0700 (PDT) From: Kees Cook To: Loic Poulain Cc: Kees Cook , Kalle Valo , wcn36xx@lists.infradead.org, linux-wireless@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] wifi: wcn36xx: Annotate struct wcn36xx_hal_ind_msg with __counted_by Date: Fri, 15 Sep 2023 13:06:27 -0700 Message-Id: <20230915200622.never.820-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1231; i=keescook@chromium.org; h=from:subject:message-id; bh=Tx0rD4QGaivxM7sy4gGEy8kvfFVy4mGnM/BvvbkoZzI=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBLlD6p2BXFHtSwKtnpPyeTLWDyraFgZ0S036T HLIIfFDiyOJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQS5QwAKCRCJcvTf3G3A JjD6D/93UiQLOjttIT0EbU7ldsmyJjtmhfaLaIneAYcFlDcgnsftgejYn1pA9AYok+xUnAnpfkp 9bViv791IaDIYWP4k7xICVG5IYyfS7++UJmcABftzpgHlbVMGImJjEYazHI67tLbGcbQBXYWc5e Ym8BsbfK9qPbjraHzs2LjoOO8CZdHH3Z7qhqffj8zZTZKVqCg8gM6YHRbOu6lgrYuhljGdvKfgC o4TcAE7B6pIhNsxLKFjTxXX/EtlJcjU1u3qaxXTsygt0vg5e75SLyTRlTJoAFpC3ZPoMMKV+QXd HwxRtLb42r+4RdH113rVtXOVQvJPUMZ/7bUzRZj1WmQpbBaFAvGX8jLI2bfRfOzlHu3oe9KTsNP 3UJlPIOac29tVYOWVc3GyU7CbYrfzr7/FV9O2uK2yUJUvQVeEk6JdHh6yadyhRzeNTD1LySHwzo Y98YLn7hXO3WHcUw7IiF4gVyRuAHC8Zjb2a92QpqBQtCCnJ4s6aNi5wEnzycdmdpdi/epGSvsBS xj5tHVSwsuKT1ul56Q2o7/B/c9m+1DbhxZG7Wv9C+qJeHHb9ZHz6mWI55QkZMz/yPk1gIq27ZZ+ HaaAk8OznFr0MKtZtid95deMwVBswNBl95zDNuIdr+z8YaicpZBr4ol4fxLSmGuiQZ+zIBRI3B7 QNnIVu0 Rm0JoYKQ== 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: X-Mailing-List: linux-wireless@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:42 -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 wcn36xx_hal_ind_msg. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Loic Poulain Cc: Kalle Valo Cc: wcn36xx@lists.infradead.org Cc: linux-wireless@vger.kernel.org Signed-off-by: Kees Cook --- drivers/net/wireless/ath/wcn36xx/smd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h index cf15cde2a364..2c1ed9e570bf 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.h +++ b/drivers/net/wireless/ath/wcn36xx/smd.h @@ -47,7 +47,7 @@ struct wcn36xx_fw_msg_status_rsp { struct wcn36xx_hal_ind_msg { struct list_head list; size_t msg_len; - u8 msg[]; + u8 msg[] __counted_by(msg_len); }; struct wcn36xx; -- 2.34.1