mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Lamparter <chunkeey@gmail.com>
To: Tristan Madani <tristmd@gmail.com>,
	Johannes Berg <johannes@sipsolutions.net>
Cc: Ivo van Doorn <ivdoorn@gmail.com>, Kees Cook <kees@kernel.org>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	tristan@talencesecurity.com
Subject: Re: [PATCH v2 wireless 3/3] wifi: p54: replace open-coded IE search with cfg80211_find_ie()
Date: Wed, 28 Oct 2026 20:03:58 +0100	[thread overview]
Message-ID: <5cecf4d8-d16d-4004-aaba-6a2c7c77ea10@gmail.com> (raw)
In-Reply-To: <20261026223222.2093813-1-tristan@talencesecurity.com>

On 10/26/26 11:32 PM, Tristan Madani wrote:
> Replace the hand-rolled p54_find_ie() with cfg80211_find_ie() at both
> call sites.  The old function had a buggy short-frame guard
> (sizeof(mgmt) compares against pointer size, not struct size) and
> open-coded the IE iteration that cfg80211_find_ie() already provides
> correctly.
> 
> Add a pre-subtraction length guard at both call sites to prevent an
> unsigned underflow when computing the IE area length from a truncated
> beacon frame.
> 
> In p54_beacon_format_ie_tim() the returned pointer is cast to non-const
> u8 * because the caller modifies the buffer via memmove(); this matches
> existing in-tree precedent (ath10k, wlcore, cw1200, nxpwifi).

Acked-by: Christian Lamparter <chunkeey@gmail.com>

> 
> Fixes: e5ea92a7528d ("p54: AP & Ad-hoc testing")
> Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
> ---
>   drivers/net/wireless/intersil/p54/lmac.h |  3 ---
>   drivers/net/wireless/intersil/p54/main.c | 30 ++++++------------------
>   drivers/net/wireless/intersil/p54/txrx.c | 12 +++++++---
>   3 files changed, 16 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/net/wireless/intersil/p54/lmac.h b/drivers/net/wireless/intersil/p54/lmac.h
> index 8adde6ba35ab8..d9cbffb74a265 100644
> --- a/drivers/net/wireless/intersil/p54/lmac.h
> +++ b/drivers/net/wireless/intersil/p54/lmac.h
> @@ -553,7 +553,4 @@ int p54_download_eeprom(struct p54_common *priv, void *buf,
>   			u16 offset, u16 len);
>   struct p54_rssi_db_entry *p54_rssi_find(struct p54_common *p, const u16 freq);
>   
> -/* utility */
> -u8 *p54_find_ie(struct sk_buff *skb, u8 ie);
> -
>   #endif /* LMAC_H */
> diff --git a/drivers/net/wireless/intersil/p54/main.c b/drivers/net/wireless/intersil/p54/main.c
> index 57a62108cbc35..30f235d470bb4 100644
> --- a/drivers/net/wireless/intersil/p54/main.c
> +++ b/drivers/net/wireless/intersil/p54/main.c
> @@ -100,12 +78,18 @@ static int p54_beacon_format_ie_tim(struct sk_buff *skb)
>   	 * The dummy TIM MUST be at the end of the beacon frame,
>   	 * because it'll be overwritten!
>   	 */
> +	struct ieee80211_mgmt *mgmt = (void *)skb->data;
> +	size_t ie_start = offsetof(struct ieee80211_mgmt, u.beacon.variable);
>   	u8 *tim;
>   	u8 dtim_len;
>   	u8 dtim_period;
>   	u8 *next;
>   
> -	tim = p54_find_ie(skb, WLAN_EID_TIM);
> +	if (skb->len < ie_start)
> +		return 0;
> +
> +	tim = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, mgmt->u.beacon.variable,
> +				    skb->len - ie_start);

casting (const u8*) to (u8 *). Oh well... If the checkers are fine with it.
Then sure.


>   	if (!tim)
>   		return 0;
>   

      reply	other threads:[~2026-10-28 19:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 22:32 Tristan Madani
2026-10-28 19:03 ` Christian Lamparter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5cecf4d8-d16d-4004-aaba-6a2c7c77ea10@gmail.com \
    --to=chunkeey@gmail.com \
    --cc=ivdoorn@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=tristan@talencesecurity.com \
    --cc=tristmd@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®