All of lore.kernel.org
 help / color / mirror / Atom feed
From: <pkshih@realtek.com>
To: <kvalo@codeaurora.org>
Cc: <yhchuang@realtek.com>, <Larry.Finger@lwfinger.net>,
	<johannes.berg@intel.com>, <linux-wireless@vger.kernel.org>
Subject: [PATCH 02/11] rtlwifi: check for array overflow
Date: Fri, 29 Dec 2017 16:31:03 +0800	[thread overview]
Message-ID: <20171229083112.31540-3-pkshih@realtek.com> (raw)
In-Reply-To: <20171229083112.31540-1-pkshih@realtek.com>

From: Dan Carpenter <dan.carpenter@oracle.com>

This is merged by Ping-Ke Shih from commit dc33bd4309d2 ("staging:
rtlwifi: check for array overflow"), and the original commit log is
reserved below.

Smatch is distrustful of the "capab" value and marks it as user
controlled.  I think it actually comes from the firmware?  Anyway, I
looked at other drivers and they added a bounds check and it seems like
a harmless thing to have so I have added it here as well.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
index 704741d6f495..2052e0e5e083 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -1321,6 +1321,10 @@ bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
 				  le16_to_cpu(mgmt->u.action.u.addba_req.capab);
 				tid = (capab &
 				       IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
+				if (tid >= MAX_TID_COUNT) {
+					rcu_read_unlock();
+					return true;
+				}
 				tid_data = &sta_entry->tids[tid];
 				if (tid_data->agg.rx_agg_state ==
 				    RTL_RX_AGG_START)
-- 
2.14.1

  parent reply	other threads:[~2017-12-29  8:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-29  8:31 [PATCH 00/11] rtlwifi: change rtlwifi maintainer and merge commits from staging pkshih
2017-12-29  8:31 ` [PATCH 01/11] MAINTAINERS: Change maintainer for rtlwifi pkshih
2018-01-08 17:14   ` [01/11] " Kalle Valo
2017-12-29  8:31 ` pkshih [this message]
2017-12-29  8:31 ` [PATCH 03/11] rtlwifi: fix parenthesis alignment pkshih
2017-12-29  8:31 ` [PATCH 04/11] rtlwifi: use kcalloc instead of multiply pkshih
2017-12-29  8:31 ` [PATCH 05/11] rtlwifi: Remove unnecessary 'out of memory' message pkshih
2017-12-29  8:31 ` [PATCH 06/11] rtlwifi: mark expected switch fall-through in rtl_make_smps_action pkshih
2017-12-29  8:31 ` [PATCH 07/11] rtlwifi: Remove unnecessary parentheses pkshih
2017-12-29  8:31 ` [PATCH 08/11] rtlwifi: rtl8723: Add error handling to no existing firmware pkshih
2017-12-29  8:31 ` [PATCH 09/11] rtlwifi: Improve debugging by using debugfs pkshih
2017-12-29  8:31 ` [PATCH 10/11] rtlwifi: btcoex: Use seq_file to dump btcoex status pkshih
2017-12-29  8:31 ` [PATCH 11/11] rtlwifi: fill FW version and subversion pkshih

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=20171229083112.31540-3-pkshih@realtek.com \
    --to=pkshih@realtek.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=johannes.berg@intel.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=yhchuang@realtek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.