linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] net: mac80211: Fix possible null-pointer dereferences in ieee80211_xmit_fast_finish()
@ 2019-07-24 12:36 Jia-Ju Bai
  2019-07-24 12:39 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2019-07-24 12:36 UTC (permalink / raw)
  To: johannes, davem; +Cc: linux-wireless, netdev, linux-kernel, Jia-Ju Bai

In ieee80211_xmit_fast_finish(), there is an if statement on line 3356
to check whether key is NULL:
    if (key)

When key is NULL, it is used on line 3388:
    switch (key->conf.cipher)
and line 3393:
    pn = atomic64_inc_return(&key->conf.tx_pn);
and line 3396:
    crypto_hdr[3] = 0x20 | (key->conf.keyidx << 6);

Thus, possible null-pointer dereferences may occur.

To fix these bugs, key is checked on line 3384.

These bugs are found by a static analysis tool STCheck written by us.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 net/mac80211/tx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index f13eb2f61ccf..2cc261165b91 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3381,7 +3381,7 @@ static void ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
 	sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
 	sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
 
-	if (pn_offs) {
+	if (key && pn_offs) {
 		u64 pn;
 		u8 *crypto_hdr = skb->data + pn_offs;
 
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] net: mac80211: Fix possible null-pointer dereferences in ieee80211_xmit_fast_finish()
  2019-07-24 12:36 [PATCH 2/2] net: mac80211: Fix possible null-pointer dereferences in ieee80211_xmit_fast_finish() Jia-Ju Bai
@ 2019-07-24 12:39 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2019-07-24 12:39 UTC (permalink / raw)
  To: Jia-Ju Bai, davem; +Cc: linux-wireless, netdev, linux-kernel

On Wed, 2019-07-24 at 20:36 +0800, Jia-Ju Bai wrote:
> In ieee80211_xmit_fast_finish(), there is an if statement on line 3356
> to check whether key is NULL:
>     if (key)
> 
> When key is NULL, it is used on line 3388:
>     switch (key->conf.cipher)
> and line 3393:
>     pn = atomic64_inc_return(&key->conf.tx_pn);
> and line 3396:
>     crypto_hdr[3] = 0x20 | (key->conf.keyidx << 6);
> 
> Thus, possible null-pointer dereferences may occur.

No, this cannot happen, because pn_offs can only be non-zero when there
is a key. Maybe we should pass the fast_tx pointer instead of the
pn_offs/key from it, but the two are coupled.

johannes


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-24 12:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-24 12:36 [PATCH 2/2] net: mac80211: Fix possible null-pointer dereferences in ieee80211_xmit_fast_finish() Jia-Ju Bai
2019-07-24 12:39 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).