* [patch] ath10k: add some sanity checks
@ 2016-04-11 7:44 Dan Carpenter
2016-04-11 7:52 ` Michal Kazior
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2016-04-11 7:44 UTC (permalink / raw)
To: Kalle Valo, Michal Kazior; +Cc: ath10k, linux-wireless, kernel-janitors
Smatch complains that since "ev->peer_id" comes from skb->data that
means we can't trust it and have to do a bounds check on it to prevent
an array overflow.
Fixes: 6942726f7f7b ('ath10k: add fast peer_map lookup')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
index 9369411..fd6ba69 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -190,6 +190,9 @@ void ath10k_peer_map_event(struct ath10k_htt *htt,
struct ath10k *ar = htt->ar;
struct ath10k_peer *peer;
+ if (ev->peer_id >= ATH10K_MAX_NUM_PEER_IDS)
+ return;
+
spin_lock_bh(&ar->data_lock);
peer = ath10k_peer_find(ar, ev->vdev_id, ev->addr);
if (!peer) {
@@ -218,6 +221,9 @@ void ath10k_peer_unmap_event(struct ath10k_htt *htt,
struct ath10k *ar = htt->ar;
struct ath10k_peer *peer;
+ if (ev->peer_id >= ATH10K_MAX_NUM_PEER_IDS)
+ return;
+
spin_lock_bh(&ar->data_lock);
peer = ath10k_peer_find_by_id(ar, ev->peer_id);
if (!peer) {
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch] ath10k: add some sanity checks
2016-04-11 7:44 [patch] ath10k: add some sanity checks Dan Carpenter
@ 2016-04-11 7:52 ` Michal Kazior
2016-04-11 8:15 ` [patch v2] " Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Michal Kazior @ 2016-04-11 7:52 UTC (permalink / raw)
To: Dan Carpenter
Cc: Kalle Valo, ath10k@lists.infradead.org, linux-wireless,
kernel-janitors
On 11 April 2016 at 09:44, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Smatch complains that since "ev->peer_id" comes from skb->data that
> means we can't trust it and have to do a bounds check on it to prevent
> an array overflow.
>
> Fixes: 6942726f7f7b ('ath10k: add fast peer_map lookup')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
> index 9369411..fd6ba69 100644
> --- a/drivers/net/wireless/ath/ath10k/txrx.c
> +++ b/drivers/net/wireless/ath/ath10k/txrx.c
> @@ -190,6 +190,9 @@ void ath10k_peer_map_event(struct ath10k_htt *htt,
> struct ath10k *ar = htt->ar;
> struct ath10k_peer *peer;
>
> + if (ev->peer_id >= ATH10K_MAX_NUM_PEER_IDS)
> + return;
> +
This will lead to a timeout in the other part of the code so printing
a warning here will make it easier to understand the failure, e.g.
ath10k_warn(ar, "received htt peer map event with idx out of bounds:
%hu\n", ev->peer_id);
> spin_lock_bh(&ar->data_lock);
> peer = ath10k_peer_find(ar, ev->vdev_id, ev->addr);
> if (!peer) {
> @@ -218,6 +221,9 @@ void ath10k_peer_unmap_event(struct ath10k_htt *htt,
> struct ath10k *ar = htt->ar;
> struct ath10k_peer *peer;
>
> + if (ev->peer_id >= ATH10K_MAX_NUM_PEER_IDS)
> + return;
Ditto but s/map/unmap.
Anyway, good catch, thanks!
Michał
^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch v2] ath10k: add some sanity checks
2016-04-11 7:52 ` Michal Kazior
@ 2016-04-11 8:15 ` Dan Carpenter
2016-04-14 14:43 ` Valo, Kalle
2016-04-19 15:47 ` Valo, Kalle
0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2016-04-11 8:15 UTC (permalink / raw)
To: Kalle Valo, Michal Kazior; +Cc: ath10k, linux-wireless, kernel-janitors
Smatch complains that since "ev->peer_id" comes from skb->data that
means we can't trust it and have to do a bounds check on it to prevent
an array overflow.
Fixes: 6942726f7f7b ('ath10k: add fast peer_map lookup')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Add a warning message. There is a checkpatch.pl warning that
the alignment should match the open parenthesis but I ignored it because
we're going off the end of the 80 character limit and this way is fine.
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
index 9369411..0885fce 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -190,6 +190,13 @@ void ath10k_peer_map_event(struct ath10k_htt *htt,
struct ath10k *ar = htt->ar;
struct ath10k_peer *peer;
+ if (ev->peer_id >= ATH10K_MAX_NUM_PEER_IDS) {
+ ath10k_warn(ar,
+ "received htt peer map event with idx out of bounds: %hu\n",
+ ev->peer_id);
+ return;
+ }
+
spin_lock_bh(&ar->data_lock);
peer = ath10k_peer_find(ar, ev->vdev_id, ev->addr);
if (!peer) {
@@ -218,6 +225,13 @@ void ath10k_peer_unmap_event(struct ath10k_htt *htt,
struct ath10k *ar = htt->ar;
struct ath10k_peer *peer;
+ if (ev->peer_id >= ATH10K_MAX_NUM_PEER_IDS) {
+ ath10k_warn(ar,
+ "received htt peer unmap event with idx out of bounds: %hu\n",
+ ev->peer_id);
+ return;
+ }
+
spin_lock_bh(&ar->data_lock);
peer = ath10k_peer_find_by_id(ar, ev->peer_id);
if (!peer) {
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch v2] ath10k: add some sanity checks
2016-04-11 8:15 ` [patch v2] " Dan Carpenter
@ 2016-04-14 14:43 ` Valo, Kalle
2016-04-19 15:47 ` Valo, Kalle
1 sibling, 0 replies; 5+ messages in thread
From: Valo, Kalle @ 2016-04-14 14:43 UTC (permalink / raw)
To: Dan Carpenter
Cc: michal.kazior@tieto.com, kernel-janitors@vger.kernel.org,
linux-wireless@vger.kernel.org, ath10k@lists.infradead.org
Dan Carpenter <dan.carpenter@oracle.com> writes:
> Smatch complains that since "ev->peer_id" comes from skb->data that
> means we can't trust it and have to do a bounds check on it to prevent
> an array overflow.
>
> Fixes: 6942726f7f7b ('ath10k: add fast peer_map lookup')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
In ath.git pending branch I modified the title to be a bit more unique:
ath10k: add some sanity checks to peer_map_event() functions
> ---
> v2: Add a warning message. There is a checkpatch.pl warning that
> the alignment should match the open parenthesis but I ignored it because
> we're going off the end of the 80 character limit and this way is fine.
In ath10k we have used 90 char limit so I fixed this in the pending
branch. And actually I don't think checkpatch complains about the
message format string length of a logging function like ath10k_warn().
--
Kalle Valo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch v2] ath10k: add some sanity checks
2016-04-11 8:15 ` [patch v2] " Dan Carpenter
2016-04-14 14:43 ` Valo, Kalle
@ 2016-04-19 15:47 ` Valo, Kalle
1 sibling, 0 replies; 5+ messages in thread
From: Valo, Kalle @ 2016-04-19 15:47 UTC (permalink / raw)
To: Dan Carpenter
Cc: michal.kazior@tieto.com, kernel-janitors@vger.kernel.org,
linux-wireless@vger.kernel.org, ath10k@lists.infradead.org
Dan Carpenter <dan.carpenter@oracle.com> writes:
> Smatch complains that since "ev->peer_id" comes from skb->data that
> means we can't trust it and have to do a bounds check on it to prevent
> an array overflow.
>
> Fixes: 6942726f7f7b ('ath10k: add fast peer_map lookup')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied, thanks.
--
Kalle Valo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-04-19 15:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-11 7:44 [patch] ath10k: add some sanity checks Dan Carpenter
2016-04-11 7:52 ` Michal Kazior
2016-04-11 8:15 ` [patch v2] " Dan Carpenter
2016-04-14 14:43 ` Valo, Kalle
2016-04-19 15:47 ` Valo, Kalle
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).