Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp949931rdb; Fri, 2 Feb 2024 08:45:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0o2TLQ/9jzFX9RiOAVhBd8kpQtVoP9yceH22USZZxW2bJcm7AV4w/05Vqc3MV/hXg9feb X-Received: by 2002:a50:9f4e:0:b0:55f:e682:c933 with SMTP id b72-20020a509f4e000000b0055fe682c933mr203437edf.12.1706892355404; Fri, 02 Feb 2024 08:45:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706892355; cv=pass; d=google.com; s=arc-20160816; b=ykNkzuyo3iBMxRKxj+uHCgN/FQ7xmgH352GcJo6FdvaR+bZB/tx3Eh1kYQFm93dAa9 G1J6Ux46LilXjn8WxcBhCAsFU5wKqu/A8atO2ZUfpMlMILwrIcAXQoSOs0xn0XTX158q FTZFsNnWvDruP4715sy9ee3Pi4q/WW6pqnaQRYx7kH8Vg/R/zNZmfy2bQHwJ6jnUv96+ jStexNNdkL17ozTPPg/TJTyZoCkPrTFVtWXqMxV/so+LaWTufqj39qU3AN+k9etrQeOe Uurv+zkrItfIkBpd2nnF7jpZZBY9K3yBFsVAAjaXs8kG6yb9N2EPyePxbbJBTghNmw1W JZ/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:message-id:user-agent:cc:to:references:in-reply-to:from :subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=agzCGzfBrAcc0co9SRxIZA0xN/6J5LrtJmO+TWeTVhU=; fh=YwicR9c7KEczYbg/kEpevaOkFB7cBa46+jsTQykCBUc=; b=Z2ZWdrjNXRAT6no2sarEOzZyEkQF7HEr798EGgv5ICyhPJ9Z6wOsrUMDM8ecErgqcn EL8AoX3tobDmJICjsPkN7DQZz50ipZGjYw1IxoqUF/UN4y8ibDv6T26f1CW96DhBeyBt LsdLKoPRSuVfX3sQ2PdiGkU0EtqQiSnS+8PF3Jne2EHlYjkEko33odYYSvgm92eCfHoJ eyIKYMkpZr8j7SWpwhXIM+khYUqBoVDRRDvdf1dos5GCVqySZVfxskLwrfug4U18w0jN HQMKlLKtkT8ImRsHxf0IiBvBljKtVKJT2d/xNm5ZagJAnKYw/WlfvhFSQnuTykn6fFsL Mvag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="lF8+cc/3"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-3045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUN0riCoJSStCZ9zJYAk6OUkvogzO1la8pFHnZVcdoLtsEDlMY24P4lcZCiOPY6/BihQEk1ILAs7Y/7HvLc68UETpSqZ68pFjJyhgIndQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g5-20020a50ee05000000b0055f63fd6152si932829eds.602.2024.02.02.08.45.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 08:45:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-3045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="lF8+cc/3"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-3045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D28951F2CA0C for ; Fri, 2 Feb 2024 16:45:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 041C21487C1; Fri, 2 Feb 2024 16:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lF8+cc/3" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD991148314; Fri, 2 Feb 2024 16:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706892348; cv=none; b=i66mOe4rKoLOJYpbVhurdAcUnmV/F0aEtUrk4WBEsc5EuiIjFPLzd4kzZ92E3llA4hvqJkf5uWzyhviLa24hyGWbHP2Y4xYoGOTs5HFkx55IOknGCJ7zJ/VC7OT7OKzukjrdvrqsC+2lU5pq6/Fw+sxZgSZEAoUrGpj+QHfX9+0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706892348; c=relaxed/simple; bh=gCXtpaaFuGj/Sfv2J/qgI4C+ehnvqwEiWJQgGM4NB5E=; h=Content-Type:MIME-Version:Subject:From:In-Reply-To:References:To: Cc:Message-ID:Date; b=Bhst7Re+cg5dwwwf/6ElmOeXdPp0gfzQbMYTawcl1gZa8gsHZDRx4DlSPk0U3FYrnYNkWDkauzDqBx/RuOLwVTjEQdUusl3hsdyD1S5m/SAPD1CWctYEA4pSk0BrxRRokEU3q4MCgjvDnR9RccMQEX9Mfuf5IvJfNLHjcoQEqP4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lF8+cc/3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 691F3C433F1; Fri, 2 Feb 2024 16:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706892348; bh=gCXtpaaFuGj/Sfv2J/qgI4C+ehnvqwEiWJQgGM4NB5E=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=lF8+cc/3GjCeNb/K2Y2/jTpo6vZYOAxO4wsHdUXD731NoAlK5/WtgIHIDumR6KnTf CmJwcmBUkmP6BwcfHG8RxV2C0kzpVwirz4iTukokWbuasbdPt51Er5Q1gZ4w82E/7D 5iYiZwhCoh9iwgWLzOhW5ki5siBeQzxVvX7dxev+zvOXdpGnrLPAVvye2FmeuWEm3Q 9VzxEn+u561Z8heuvD0IwmWe2mi+r0FKED1GxpXx6BRRtasDbC8e7AGizIVvPEra8y rk0D98GTJm6RD0K1FFjPFzJPLFFAbNwOSlGeSZBJ1hQt0XmC0sLgyFnx5BOzbIccio i67hwtIH6pSAg== Content-Type: text/plain; charset="utf-8" Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PATCH] wifi: brcmfmac: Adjust n_channels usage for __counted_by From: Kalle Valo In-Reply-To: <20240126223150.work.548-kees@kernel.org> References: <20240126223150.work.548-kees@kernel.org> To: Kees Cook Cc: Arend van Spriel , Kees Cook , Franky Lin , Hante Meuleman , Chi-hsien Lin , Ian Lin , Johannes Berg , Wright Feng , Hector Martin , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, "Gustavo A. R. Silva" , Linus Walleij , Jisoo Jang , Hans de Goede , Aloka Dixit , John Keeping , Jeff Johnson , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org User-Agent: pwcli/0.1.1-git (https://github.com/kvalo/pwcli/) Python/3.11.2 Message-ID: <170689233342.3493863.10294472294618285046.kvalo@kernel.org> Date: Fri, 2 Feb 2024 16:45:37 +0000 (UTC) Kees Cook wrote: > After commit e3eac9f32ec0 ("wifi: cfg80211: Annotate struct > cfg80211_scan_request with __counted_by"), the compiler may enforce > dynamic array indexing of req->channels to stay below n_channels. As a > result, n_channels needs to be increased _before_ accessing the newly > added array index. Increment it first, then use "i" for the prior index. > Solves this warning in the coming GCC that has __counted_by support: > > ../drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c: In function 'brcmf_internal_escan_add_info': > ../drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:3783:46: warning: operation on 'req-> > n_channels' may be undefined [-Wsequence-point] > 3783 | req->channels[req->n_channels++] = chan; > | ~~~~~~~~~~~~~~~^~ > > Fixes: e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by") > Cc: Arend van Spriel > Cc: Franky Lin > Cc: Hante Meuleman > Cc: Kalle Valo > Cc: Chi-hsien Lin > Cc: Ian Lin > Cc: Johannes Berg > Cc: Wright Feng > Cc: Hector Martin > Cc: linux-wireless@vger.kernel.org > Cc: brcm80211-dev-list.pdl@broadcom.com > Signed-off-by: Kees Cook > Reviewed-by: Hans de Goede > Reviewed-by: Linus Walleij > Reviewed-by: Gustavo A. R. Silva Patch applied to wireless.git, thanks. 5bdda0048c8d wifi: brcmfmac: Adjust n_channels usage for __counted_by -- https://patchwork.kernel.org/project/linux-wireless/patch/20240126223150.work.548-kees@kernel.org/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches