From patchwork Thu Oct 24 11:29:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 839022 Received: from forward101d.mail.yandex.net (forward101d.mail.yandex.net [178.154.239.212]) (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 E267B1CFEA9; Thu, 24 Oct 2024 11:30:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.212 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729769404; cv=none; b=NgHm+zW3hXUHh7NWhQHTPq/EXV06OzSEsHpZmEnmIrO6w95fp0A7iEczV4Ty0fmog4u+dQ9tVvEn2/cl0om/it9tuVkpNMsUGnuynRB8RtINObuECJA353AS7yShR5YRydqE691cG7hjMD8LvjVi1K5X7/9IqGqsLIBslZMMCjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729769404; c=relaxed/simple; bh=Es75ymu6TA/72wlDe6DDLYMi/A2MnDf7PCeFMC1cgZI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Wi8X34UzfOaxjZyoIcPRz+/0D+BUJPh6IInKuF/NgAUn8bEIuzaevkbzzDXsEsKsrTrNOlaLjgDq9GNLouSxlgNgmSM0gPHYypfs0QYW0JoSvluvh5Sm0Cur0eldIHfFZS5TTr7W6IIWeZVeC/LXwl8jPa8akE7+WnD4EPNDqX8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru; spf=pass smtp.mailfrom=yandex.ru; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b=JOJfgHMx; arc=none smtp.client-ip=178.154.239.212 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="JOJfgHMx" Received: from mail-nwsmtp-smtp-production-main-77.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-77.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:3e0b:0:640:c81:0]) by forward101d.mail.yandex.net (Yandex) with ESMTPS id 0CC126098B; Thu, 24 Oct 2024 14:29:54 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-77.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id oTSTCcEXxKo0-UX2muSCE; Thu, 24 Oct 2024 14:29:53 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1729769393; bh=++B3dviPbcmr1FsTl+ZLaUiYpKOFDaZ1XAfNcpeoR9s=; h=Message-ID:Date:Cc:Subject:To:From; b=JOJfgHMxsjwfzb6e7ZRo572aX5p16jgqex2ssh8DF6cH4XPKnPEQN8V6R8USJLoT9 A+UslEmN8ffoG8cwhxNtUPZRs9l9Y0YvfG5n+6NAbXjjtzpfoVp4WoFL/QRm8u1Cg6 +rtyQA3ulg6pOFwIb34gcP3eeGhmUfP5Q2Zo1lGE= Authentication-Results: mail-nwsmtp-smtp-production-main-77.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Jeff Johnson Cc: Kalle Valo , Kees Cook , "Gustavo A . R . Silva" , linux-wireless@vger.kernel.org, linux-hardening@vger.kernel.org, lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH v2 1/2] wifi: ath12k: annotate skb of struct ath12k_ce_ring with __counted_by Date: Thu, 24 Oct 2024 14:29:11 +0300 Message-ID: <20241024112912.106104-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 According to 'ath12k_ce_alloc_ring()', annotate flexible array member 'skb' of 'struct ath12k_ce_ring' with '__counted_by()' to improve runtime bounds checking when CONFIG_UBSAN_BOUNDS is enabled. Compile tested only. Signed-off-by: Dmitry Antipov --- v2: add related comment in ath12k_ce_alloc_ring() --- drivers/net/wireless/ath/ath12k/ce.c | 3 +++ drivers/net/wireless/ath/ath12k/ce.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath12k/ce.c b/drivers/net/wireless/ath/ath12k/ce.c index be0d669d31fc..23d984da2341 100644 --- a/drivers/net/wireless/ath/ath12k/ce.c +++ b/drivers/net/wireless/ath/ath12k/ce.c @@ -550,6 +550,9 @@ ath12k_ce_alloc_ring(struct ath12k_base *ab, int nentries, int desc_sz) if (!ce_ring) return ERR_PTR(-ENOMEM); + /* Note nentries should be set before populating skb[], + * otherwise __counted_by() might raise false positives. + */ ce_ring->nentries = nentries; ce_ring->nentries_mask = nentries - 1; diff --git a/drivers/net/wireless/ath/ath12k/ce.h b/drivers/net/wireless/ath/ath12k/ce.h index 857bc5f9e946..6967e3891030 100644 --- a/drivers/net/wireless/ath/ath12k/ce.h +++ b/drivers/net/wireless/ath/ath12k/ce.h @@ -135,7 +135,7 @@ struct ath12k_ce_ring { u32 hal_ring_id; /* keep last */ - struct sk_buff *skb[]; + struct sk_buff *skb[] __counted_by(nentries); }; struct ath12k_ce_pipe { From patchwork Thu Oct 24 11:29:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 838326 Received: from forward100a.mail.yandex.net (forward100a.mail.yandex.net [178.154.239.83]) (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 54C951CF295; Thu, 24 Oct 2024 11:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729769401; cv=none; b=crgZ/K0hJI1KLG3BO5skqhnkdIKhrWvU4ECzZIXR3FSlfH/D6ND13LXONOmYznnYhlb+MQa3pQz9xeaOCDo5H/ZwxeHaGAEuKs/VXqw577S6jfIDV06nOZcBm9UEc0PgCiZTICeiR7AeD2cWpBVNkHXYuNesC77rWOgdF8hI5YM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729769401; c=relaxed/simple; bh=nDWU0O1vn5ngbJToDYeqUZGhEDVSV8kfu0i38xckejU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CxVOqQcAjiuZZX4bxiQznS+PlBc8kkfsDar77w5mCKIoDJZoNjXaOykv38JGp86s5rb/hwCZZuiDnj8LS407CwFERd9iu+UwlfEBNowiq3caMeqAfEddGJdKcnMZ7I9ylCULnpH9BBkdvWKZ+5GBrCAge5aW1FxbRbEQQp8SIhE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru; spf=pass smtp.mailfrom=yandex.ru; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b=wrkWD0dW; arc=none smtp.client-ip=178.154.239.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="wrkWD0dW" Received: from mail-nwsmtp-smtp-production-main-77.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-77.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:3e0b:0:640:c81:0]) by forward100a.mail.yandex.net (Yandex) with ESMTPS id 9B0F446EE4; Thu, 24 Oct 2024 14:29:56 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-77.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id oTSTCcEXxKo0-oCYzBIe4; Thu, 24 Oct 2024 14:29:55 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1729769395; bh=uVIY/XG3B4mLRa5gqLMjSJGb7yZMvMoSYtpC3HeQrSU=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=wrkWD0dWLqOZ1ZY6N/C/fqfTW4XS4nYXNx9NZtTSaX13erZWL4Ujch8zr1EL3TKmD iX08gz8gf+EgQ+ai1ZdmYd8DjWIKYMJkgEvldYau9cLRvQcuPfReZncHNNH/MyB9f4 3udw25otROcyKmfx3XM92VSLR8HfooWnYz/4S0DY= Authentication-Results: mail-nwsmtp-smtp-production-main-77.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Jeff Johnson Cc: Kalle Valo , Kees Cook , "Gustavo A . R . Silva" , linux-wireless@vger.kernel.org, linux-hardening@vger.kernel.org, lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH v2 2/2] wifi: ath12k: annotate channel of struct ath12k_wmi_scan_chan_list_arg with __counted_by Date: Thu, 24 Oct 2024 14:29:12 +0300 Message-ID: <20241024112912.106104-2-dmantipov@yandex.ru> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241024112912.106104-1-dmantipov@yandex.ru> References: <20241024112912.106104-1-dmantipov@yandex.ru> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 According to 'ath12k_reg_update_chan_list()', annotate flexible array member 'channel' of 'struct ath12k_wmi_scan_chan_list_arg' with '__counted_by()' attribute to improve runtime bounds checking when CONFIG_UBSAN_BOUNDS is enabled. Compile tested only. Signed-off-by: Dmitry Antipov --- v2: fix typo and add related comment in ath12k_reg_update_chan_list() --- drivers/net/wireless/ath/ath12k/reg.c | 3 +++ drivers/net/wireless/ath/ath12k/wmi.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c index 439d61f284d8..dbd6f0570498 100644 --- a/drivers/net/wireless/ath/ath12k/reg.c +++ b/drivers/net/wireless/ath/ath12k/reg.c @@ -131,6 +131,9 @@ int ath12k_reg_update_chan_list(struct ath12k *ar) return -ENOMEM; arg->pdev_id = ar->pdev->pdev_id; + /* Note nallchans should be set before populating channel[], + * otherwise __counted_by() might raise false positives. + */ arg->nallchans = num_channels; ch = arg->channel; diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h index 6a913f9b8315..02b3d722a23b 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.h +++ b/drivers/net/wireless/ath/ath12k/wmi.h @@ -3746,7 +3746,7 @@ struct wmi_stop_scan_cmd { struct ath12k_wmi_scan_chan_list_arg { u32 pdev_id; u16 nallchans; - struct ath12k_wmi_channel_arg channel[]; + struct ath12k_wmi_channel_arg channel[] __counted_by(nallchans); }; struct wmi_scan_chan_list_cmd {