This repository has been archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0001-BACKPORT-CVE-2018-11878-wlan-Use-request-manager-while-processing-d.patch
227 lines (205 loc) · 7.41 KB
/
0001-BACKPORT-CVE-2018-11878-wlan-Use-request-manager-while-processing-d.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
From 83b418344257bbedb6fa96f70ecf8983ba3e5e7a Mon Sep 17 00:00:00 2001
From: Hanumanth Reddy Pothula <[email protected]>
Date: Thu, 17 May 2018 13:13:01 +0530
Subject: [PATCH 1/2] BACKPORT: wlan: Use request manager while processing
driver commands
We are transitioning to the new request manager framework. Change
hdd_driver_command() to this framework.
Change-Id: Ia486bb4f8a8dd638665b0501d124f5c25f9db99b
CRs-Fixed: 2228608
CVE-2018-11878
---
drivers/staging/prima/CORE/HDD/src/wlan_hdd_main.c | 151 ++++++++++++++-------
1 file changed, 101 insertions(+), 50 deletions(-)
diff --git a/drivers/staging/prima/CORE/HDD/src/wlan_hdd_main.c b/drivers/staging/prima/CORE/HDD/src/wlan_hdd_main.c
index b6b25d61f41f..c47dde52a4fd 100644
--- a/drivers/staging/prima/CORE/HDD/src/wlan_hdd_main.c
+++ b/drivers/staging/prima/CORE/HDD/src/wlan_hdd_main.c
@@ -1920,46 +1920,84 @@ exit:
#endif/*End of FEATURE_WLAN_BATCH_SCAN*/
-static void getBcnMissRateCB(VOS_STATUS status, int bcnMissRate, void *data)
-{
- bcnMissRateContext_t *pCBCtx;
+struct bcn_miss_rate_priv {
+ int bcn_miss_rate;
+};
- if (NULL == data)
- {
- hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL"));
+/**
+ * get_bcn_miss_rate_cb() callback invoked on receiving beacon miss
+ * rate from firmware
+ * @status: Status of get beacon miss rate operation
+ * @bcnMissRate: Beacon miss rate
+ * @context: Context passed while registering callback
+ *
+ * This function is invoked by WDA layer on receiving
+ * WDI_GET_BCN_MISS_RATE_RSP
+ *
+ * Return: None
+ */
+static void get_bcn_miss_rate_cb(VOS_STATUS status, int bcnMissRate,
+ void *context)
+{
+ struct hdd_request *request;
+ struct bcn_miss_rate_priv *priv;
+ request = hdd_request_get(context);
+ if (!request) {
+ hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
+ return;
+ }
+
+ priv = hdd_request_priv(request);
+
+ if (VOS_STATUS_SUCCESS == status)
+ priv->bcn_miss_rate = bcnMissRate;
+ else
+ hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate"));
+
+ hdd_request_complete(request);
+ hdd_request_put(request);
return;
- }
+}
- /* there is a race condition that exists between this callback
- function and the caller since the caller could time out either
- before or while this code is executing. we use a spinlock to
- serialize these actions */
- spin_lock(&hdd_context_lock);
+struct fw_stats_priv {
+ tSirFwStatsResult *fw_stats;
+};
- pCBCtx = (bcnMissRateContext_t *)data;
- gbcnMissRate = -1;
+/**
+ * hdd_fw_stats_cb() callback invoked on receiving firmware stats
+ * from firmware
+ * @status: Status of get firmware stats operation
+ * @fwStatsResult: firmware stats
+ * @context: Context passed while registering callback
+ *
+ * This function is invoked by WDA layer on receiving
+ * WDI_GET_FW_STATS_RSP
+ *
+ * Return: None
+ */
+static void hdd_fw_stats_cb(VOS_STATUS status,
+ tSirFwStatsResult *fwStatsResult, void *context)
+{
+ struct hdd_request *request;
+ struct fw_stats_priv *priv;
- if (pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC)
- {
- hddLog(VOS_TRACE_LEVEL_ERROR,
- FL("invalid context magic: %08x"), pCBCtx->magic);
- spin_unlock(&hdd_context_lock);
- return ;
- }
+ hddLog(VOS_TRACE_LEVEL_INFO, FL("with status = %d"),status);
- if (VOS_STATUS_SUCCESS == status)
- {
- gbcnMissRate = bcnMissRate;
- }
- else
- {
- hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate"));
- }
+ request = hdd_request_get(context);
+ if (!request) {
+ hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
+ return;
+ }
+ priv = hdd_request_priv(request);
- complete(&(pCBCtx->completion));
- spin_unlock(&hdd_context_lock);
+ if (VOS_STATUS_SUCCESS == status)
+ *priv->fw_stats = *fwStatsResult;
+ else
+ priv->fw_stats = NULL;
- return;
+ hdd_request_complete(request);
+ hdd_request_put(request);
+ return;
}
static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len)
@@ -4056,8 +4094,13 @@ static int hdd_driver_command(hdd_adapter_t *pAdapter,
{
eHalStatus status;
char buf[32], len;
- long waitRet;
- bcnMissRateContext_t getBcnMissRateCtx;
+ void *cookie;
+ struct hdd_request *request;
+ struct bcn_miss_rate_priv *priv;
+ static const struct hdd_request_params params = {
+ .priv_size = sizeof(*priv),
+ .timeout_ms = WLAN_WAIT_TIME_STATS,
+ };
hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
@@ -4069,46 +4112,54 @@ static int hdd_driver_command(hdd_adapter_t *pAdapter,
goto exit;
}
- init_completion(&(getBcnMissRateCtx.completion));
- getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC;
+ request = hdd_request_alloc(¶ms);
+ if (!request) {
+ hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
+ ret = -ENOMEM;
+ goto exit;
+ }
+ cookie = hdd_request_cookie(request);
+ priv = hdd_request_priv(request);
+ priv->bcn_miss_rate = -1;
status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal),
pAdapter->sessionId,
- (void *)getBcnMissRateCB,
- (void *)(&getBcnMissRateCtx));
+ (void *)get_bcn_miss_rate_cb,
+ cookie);
if( eHAL_STATUS_SUCCESS != status)
{
hddLog(VOS_TRACE_LEVEL_INFO,
FL("GETBCNMISSRATE: fail to post WDA cmd"));
ret = -EINVAL;
- goto exit;
+ goto free_bcn_miss_rate_req;
}
- waitRet = wait_for_completion_interruptible_timeout
- (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME);
- if(waitRet <= 0)
+ ret = hdd_request_wait_for_response(request);
+ if(ret)
{
hddLog(VOS_TRACE_LEVEL_ERROR,
FL("failed to wait on bcnMissRateComp %d"), ret);
- //Make magic number to zero so that callback is not called.
- spin_lock(&hdd_context_lock);
- getBcnMissRateCtx.magic = 0x0;
- spin_unlock(&hdd_context_lock);
ret = -EINVAL;
- goto exit;
+ goto free_bcn_miss_rate_req;
}
hddLog(VOS_TRACE_LEVEL_INFO,
- FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate);
+ FL("GETBCNMISSRATE: bcnMissRate: %d"), priv->bcn_miss_rate);
- len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate);
+ if (priv->bcn_miss_rate == -1) {
+ ret = -EFAULT;
+ goto free_bcn_miss_rate_req;
+ }
+
+ len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d",
+ priv->bcn_miss_rate);
if (copy_to_user(priv_data.buf, &buf, len + 1))
{
hddLog(VOS_TRACE_LEVEL_ERROR,
"%s: failed to copy data to user buffer", __func__);
ret = -EFAULT;
- goto exit;
+ goto free_bcn_miss_rate_req;
}
ret = len;
}
--
2.11.0