2023-08-08 15:59:01

by Dmitry Antipov

[permalink] [raw]
Subject: [PATCH 1/2] wifi: ath10k: do not ignore value returned by ath10k_wmi_peer_set_param()

Do not ignore value returned by 'ath10k_wmi_peer_set_param()' but
rather propagate it as the return value of the 'ath10k_set_key()'.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 9cdd00575029 ("ath10k: fix TDLS peer TX data failure issue on encryped AP")
Fixes: 382e51c139ef ("ath10k: set WMI_PEER_AUTHORIZE after a firmware crash")
Signed-off-by: Dmitry Antipov <[email protected]>
---
drivers/net/wireless/ath/ath10k/mac.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 03e7bc5b6c0b..22e5ee151c49 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -6663,12 +6663,14 @@ static int ath10k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
spin_unlock_bh(&ar->data_lock);

if (sta && sta->tdls)
- ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr,
- ar->wmi.peer_param->authorize, 1);
- else if (sta && cmd == SET_KEY && (key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
- ath10k_wmi_peer_set_param(ar, arvif->vdev_id, peer_addr,
- ar->wmi.peer_param->authorize, 1);
-
+ ret = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr,
+ ar->wmi.peer_param->authorize,
+ 1);
+ else if (sta && cmd == SET_KEY &&
+ (key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
+ ret = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, peer_addr,
+ ar->wmi.peer_param->authorize,
+ 1);
exit:
mutex_unlock(&ar->conf_mutex);
return ret;
--
2.41.0



2023-08-08 16:01:59

by Dmitry Antipov

[permalink] [raw]
Subject: [PATCH 2/2] wifi: ath10k: consistently use kstrtoX_from_user() functions

Use 'kstrtoul_from_user()', 'kstrtouint_from_user()', and
'kstrtobool_from_user()' where appropriate and thus avoid
some code duplication.

Signed-off-by: Dmitry Antipov <[email protected]>
---
drivers/net/wireless/ath/ath10k/debug.c | 41 ++++++----------------
drivers/net/wireless/ath/ath10k/spectral.c | 26 +++++---------
2 files changed, 19 insertions(+), 48 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index f9518e1c9903..07a92f5296b6 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -1964,20 +1964,13 @@ static ssize_t ath10k_write_btcoex(struct file *file,
size_t count, loff_t *ppos)
{
struct ath10k *ar = file->private_data;
- char buf[32];
- size_t buf_size;
int ret;
bool val;
u32 pdev_param;

- buf_size = min(count, (sizeof(buf) - 1));
- if (copy_from_user(buf, ubuf, buf_size))
- return -EFAULT;
-
- buf[buf_size] = '\0';
-
- if (kstrtobool(buf, &val) != 0)
- return -EINVAL;
+ ret = kstrtobool_from_user(ubuf, count, &val);
+ if (ret)
+ return ret;

if (!ar->coex_support)
return -EOPNOTSUPP;
@@ -2103,19 +2096,12 @@ static ssize_t ath10k_write_peer_stats(struct file *file,
size_t count, loff_t *ppos)
{
struct ath10k *ar = file->private_data;
- char buf[32];
- size_t buf_size;
int ret;
bool val;

- buf_size = min(count, (sizeof(buf) - 1));
- if (copy_from_user(buf, ubuf, buf_size))
- return -EFAULT;
-
- buf[buf_size] = '\0';
-
- if (kstrtobool(buf, &val) != 0)
- return -EINVAL;
+ ret = kstrtobool_from_user(ubuf, count, &val);
+ if (ret)
+ return ret;

mutex_lock(&ar->conf_mutex);

@@ -2239,21 +2225,16 @@ static ssize_t ath10k_sta_tid_stats_mask_write(struct file *file,
size_t count, loff_t *ppos)
{
struct ath10k *ar = file->private_data;
- char buf[32];
- ssize_t len;
u32 mask;
+ int ret;

- len = min(count, sizeof(buf) - 1);
- if (copy_from_user(buf, user_buf, len))
- return -EFAULT;
-
- buf[len] = '\0';
- if (kstrtoint(buf, 0, &mask))
- return -EINVAL;
+ ret = kstrtouint_from_user(user_buf, count, 0, &mask);
+ if (ret)
+ return ret;

ar->sta_tid_stats_mask = mask;

- return len;
+ return count;
}

static const struct file_operations fops_sta_tid_stats_mask = {
diff --git a/drivers/net/wireless/ath/ath10k/spectral.c b/drivers/net/wireless/ath/ath10k/spectral.c
index 68254a967ccb..2240994390ed 100644
--- a/drivers/net/wireless/ath/ath10k/spectral.c
+++ b/drivers/net/wireless/ath/ath10k/spectral.c
@@ -384,16 +384,11 @@ static ssize_t write_file_spectral_count(struct file *file,
{
struct ath10k *ar = file->private_data;
unsigned long val;
- char buf[32];
- ssize_t len;
-
- len = min(count, sizeof(buf) - 1);
- if (copy_from_user(buf, user_buf, len))
- return -EFAULT;
+ ssize_t ret;

- buf[len] = '\0';
- if (kstrtoul(buf, 0, &val))
- return -EINVAL;
+ ret = kstrtoul_from_user(user_buf, count, 0, &val);
+ if (ret)
+ return ret;

if (val > 255)
return -EINVAL;
@@ -440,16 +435,11 @@ static ssize_t write_file_spectral_bins(struct file *file,
{
struct ath10k *ar = file->private_data;
unsigned long val;
- char buf[32];
- ssize_t len;
-
- len = min(count, sizeof(buf) - 1);
- if (copy_from_user(buf, user_buf, len))
- return -EFAULT;
+ ssize_t ret;

- buf[len] = '\0';
- if (kstrtoul(buf, 0, &val))
- return -EINVAL;
+ ret = kstrtoul_from_user(user_buf, count, 0, &val);
+ if (ret)
+ return ret;

if (val < 64 || val > SPECTRAL_ATH10K_MAX_NUM_BINS)
return -EINVAL;
--
2.41.0


2023-08-08 18:15:57

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 1/2] wifi: ath10k: do not ignore value returned by ath10k_wmi_peer_set_param()

ath10k patches should also cc: [email protected]

Please take advantage of the get_maintainer.pl script to make sure you
copy all appropriate lists since you seem to be touching a large number
of drivers and subsystems.