diff options
author | Markos Chandras <markos.chandras@imgtec.com> | 2014-01-03 09:55:02 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-03-26 18:09:16 -0400 |
commit | e3a9b07a9caf4e490eee2c0645530cdc80a685f2 (patch) | |
tree | 3ffe0996be570d0767da8e73bf90628801e2ec53 /arch/mips/include/asm | |
parent | 05c6516005c47c3b11582eec2137908ce1afe316 (diff) |
MIPS: asm: uaccess: Add EVA support for str*_user operations
The str*_user functions are used to securely access NULL terminated
strings from userland. Therefore, it's necessary to use the appropriate
EVA function. However, if the string is in kernel space, then the normal
instructions are being used to access it. The __str*_kernel_asm and
__str*_user_asm symbols are the same for non-EVA mode so there is no
functional change for the non-EVA kernels.
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Diffstat (limited to 'arch/mips/include/asm')
-rw-r--r-- | arch/mips/include/asm/uaccess.h | 172 |
1 files changed, 119 insertions, 53 deletions
diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h index 98f4a7934529..a10951090234 100644 --- a/arch/mips/include/asm/uaccess.h +++ b/arch/mips/include/asm/uaccess.h | |||
@@ -1246,16 +1246,28 @@ __strncpy_from_user(char *__to, const char __user *__from, long __len) | |||
1246 | { | 1246 | { |
1247 | long res; | 1247 | long res; |
1248 | 1248 | ||
1249 | might_fault(); | 1249 | if (segment_eq(get_fs(), get_ds())) { |
1250 | __asm__ __volatile__( | 1250 | __asm__ __volatile__( |
1251 | "move\t$4, %1\n\t" | 1251 | "move\t$4, %1\n\t" |
1252 | "move\t$5, %2\n\t" | 1252 | "move\t$5, %2\n\t" |
1253 | "move\t$6, %3\n\t" | 1253 | "move\t$6, %3\n\t" |
1254 | __MODULE_JAL(__strncpy_from_user_nocheck_asm) | 1254 | __MODULE_JAL(__strncpy_from_kernel_nocheck_asm) |
1255 | "move\t%0, $2" | 1255 | "move\t%0, $2" |
1256 | : "=r" (res) | 1256 | : "=r" (res) |
1257 | : "r" (__to), "r" (__from), "r" (__len) | 1257 | : "r" (__to), "r" (__from), "r" (__len) |
1258 | : "$2", "$3", "$4", "$5", "$6", __UA_t0, "$31", "memory"); | 1258 | : "$2", "$3", "$4", "$5", "$6", __UA_t0, "$31", "memory"); |
1259 | } else { | ||
1260 | might_fault(); | ||
1261 | __asm__ __volatile__( | ||
1262 | "move\t$4, %1\n\t" | ||
1263 | "move\t$5, %2\n\t" | ||
1264 | "move\t$6, %3\n\t" | ||
1265 | __MODULE_JAL(__strncpy_from_user_nocheck_asm) | ||
1266 | "move\t%0, $2" | ||
1267 | : "=r" (res) | ||
1268 | : "r" (__to), "r" (__from), "r" (__len) | ||
1269 | : "$2", "$3", "$4", "$5", "$6", __UA_t0, "$31", "memory"); | ||
1270 | } | ||
1259 | 1271 | ||
1260 | return res; | 1272 | return res; |
1261 | } | 1273 | } |
@@ -1283,16 +1295,28 @@ strncpy_from_user(char *__to, const char __user *__from, long __len) | |||
1283 | { | 1295 | { |
1284 | long res; | 1296 | long res; |
1285 | 1297 | ||
1286 | might_fault(); | 1298 | if (segment_eq(get_fs(), get_ds())) { |
1287 | __asm__ __volatile__( | 1299 | __asm__ __volatile__( |
1288 | "move\t$4, %1\n\t" | 1300 | "move\t$4, %1\n\t" |
1289 | "move\t$5, %2\n\t" | 1301 | "move\t$5, %2\n\t" |
1290 | "move\t$6, %3\n\t" | 1302 | "move\t$6, %3\n\t" |
1291 | __MODULE_JAL(__strncpy_from_user_asm) | 1303 | __MODULE_JAL(__strncpy_from_kernel_asm) |
1292 | "move\t%0, $2" | 1304 | "move\t%0, $2" |
1293 | : "=r" (res) | 1305 | : "=r" (res) |
1294 | : "r" (__to), "r" (__from), "r" (__len) | 1306 | : "r" (__to), "r" (__from), "r" (__len) |
1295 | : "$2", "$3", "$4", "$5", "$6", __UA_t0, "$31", "memory"); | 1307 | : "$2", "$3", "$4", "$5", "$6", __UA_t0, "$31", "memory"); |
1308 | } else { | ||
1309 | might_fault(); | ||
1310 | __asm__ __volatile__( | ||
1311 | "move\t$4, %1\n\t" | ||
1312 | "move\t$5, %2\n\t" | ||
1313 | "move\t$6, %3\n\t" | ||
1314 | __MODULE_JAL(__strncpy_from_user_asm) | ||
1315 | "move\t%0, $2" | ||
1316 | : "=r" (res) | ||
1317 | : "r" (__to), "r" (__from), "r" (__len) | ||
1318 | : "$2", "$3", "$4", "$5", "$6", __UA_t0, "$31", "memory"); | ||
1319 | } | ||
1296 | 1320 | ||
1297 | return res; | 1321 | return res; |
1298 | } | 1322 | } |
@@ -1302,14 +1326,24 @@ static inline long __strlen_user(const char __user *s) | |||
1302 | { | 1326 | { |
1303 | long res; | 1327 | long res; |
1304 | 1328 | ||
1305 | might_fault(); | 1329 | if (segment_eq(get_fs(), get_ds())) { |
1306 | __asm__ __volatile__( | 1330 | __asm__ __volatile__( |
1307 | "move\t$4, %1\n\t" | 1331 | "move\t$4, %1\n\t" |
1308 | __MODULE_JAL(__strlen_user_nocheck_asm) | 1332 | __MODULE_JAL(__strlen_kernel_nocheck_asm) |
1309 | "move\t%0, $2" | 1333 | "move\t%0, $2" |
1310 | : "=r" (res) | 1334 | : "=r" (res) |
1311 | : "r" (s) | 1335 | : "r" (s) |
1312 | : "$2", "$4", __UA_t0, "$31"); | 1336 | : "$2", "$4", __UA_t0, "$31"); |
1337 | } else { | ||
1338 | might_fault(); | ||
1339 | __asm__ __volatile__( | ||
1340 | "move\t$4, %1\n\t" | ||
1341 | __MODULE_JAL(__strlen_user_nocheck_asm) | ||
1342 | "move\t%0, $2" | ||
1343 | : "=r" (res) | ||
1344 | : "r" (s) | ||
1345 | : "$2", "$4", __UA_t0, "$31"); | ||
1346 | } | ||
1313 | 1347 | ||
1314 | return res; | 1348 | return res; |
1315 | } | 1349 | } |
@@ -1332,14 +1366,24 @@ static inline long strlen_user(const char __user *s) | |||
1332 | { | 1366 | { |
1333 | long res; | 1367 | long res; |
1334 | 1368 | ||
1335 | might_fault(); | 1369 | if (segment_eq(get_fs(), get_ds())) { |
1336 | __asm__ __volatile__( | 1370 | __asm__ __volatile__( |
1337 | "move\t$4, %1\n\t" | 1371 | "move\t$4, %1\n\t" |
1338 | __MODULE_JAL(__strlen_user_asm) | 1372 | __MODULE_JAL(__strlen_kernel_asm) |
1339 | "move\t%0, $2" | 1373 | "move\t%0, $2" |
1340 | : "=r" (res) | 1374 | : "=r" (res) |
1341 | : "r" (s) | 1375 | : "r" (s) |
1342 | : "$2", "$4", __UA_t0, "$31"); | 1376 | : "$2", "$4", __UA_t0, "$31"); |
1377 | } else { | ||
1378 | might_fault(); | ||
1379 | __asm__ __volatile__( | ||
1380 | "move\t$4, %1\n\t" | ||
1381 | __MODULE_JAL(__strlen_kernel_asm) | ||
1382 | "move\t%0, $2" | ||
1383 | : "=r" (res) | ||
1384 | : "r" (s) | ||
1385 | : "$2", "$4", __UA_t0, "$31"); | ||
1386 | } | ||
1343 | 1387 | ||
1344 | return res; | 1388 | return res; |
1345 | } | 1389 | } |
@@ -1349,15 +1393,26 @@ static inline long __strnlen_user(const char __user *s, long n) | |||
1349 | { | 1393 | { |
1350 | long res; | 1394 | long res; |
1351 | 1395 | ||
1352 | might_fault(); | 1396 | if (segment_eq(get_fs(), get_ds())) { |
1353 | __asm__ __volatile__( | 1397 | __asm__ __volatile__( |
1354 | "move\t$4, %1\n\t" | 1398 | "move\t$4, %1\n\t" |
1355 | "move\t$5, %2\n\t" | 1399 | "move\t$5, %2\n\t" |
1356 | __MODULE_JAL(__strnlen_user_nocheck_asm) | 1400 | __MODULE_JAL(__strnlen_kernel_nocheck_asm) |
1357 | "move\t%0, $2" | 1401 | "move\t%0, $2" |
1358 | : "=r" (res) | 1402 | : "=r" (res) |
1359 | : "r" (s), "r" (n) | 1403 | : "r" (s), "r" (n) |
1360 | : "$2", "$4", "$5", __UA_t0, "$31"); | 1404 | : "$2", "$4", "$5", __UA_t0, "$31"); |
1405 | } else { | ||
1406 | might_fault(); | ||
1407 | __asm__ __volatile__( | ||
1408 | "move\t$4, %1\n\t" | ||
1409 | "move\t$5, %2\n\t" | ||
1410 | __MODULE_JAL(__strnlen_user_nocheck_asm) | ||
1411 | "move\t%0, $2" | ||
1412 | : "=r" (res) | ||
1413 | : "r" (s), "r" (n) | ||
1414 | : "$2", "$4", "$5", __UA_t0, "$31"); | ||
1415 | } | ||
1361 | 1416 | ||
1362 | return res; | 1417 | return res; |
1363 | } | 1418 | } |
@@ -1381,14 +1436,25 @@ static inline long strnlen_user(const char __user *s, long n) | |||
1381 | long res; | 1436 | long res; |
1382 | 1437 | ||
1383 | might_fault(); | 1438 | might_fault(); |
1384 | __asm__ __volatile__( | 1439 | if (segment_eq(get_fs(), get_ds())) { |
1385 | "move\t$4, %1\n\t" | 1440 | __asm__ __volatile__( |
1386 | "move\t$5, %2\n\t" | 1441 | "move\t$4, %1\n\t" |
1387 | __MODULE_JAL(__strnlen_user_asm) | 1442 | "move\t$5, %2\n\t" |
1388 | "move\t%0, $2" | 1443 | __MODULE_JAL(__strnlen_kernel_asm) |
1389 | : "=r" (res) | 1444 | "move\t%0, $2" |
1390 | : "r" (s), "r" (n) | 1445 | : "=r" (res) |
1391 | : "$2", "$4", "$5", __UA_t0, "$31"); | 1446 | : "r" (s), "r" (n) |
1447 | : "$2", "$4", "$5", __UA_t0, "$31"); | ||
1448 | } else { | ||
1449 | __asm__ __volatile__( | ||
1450 | "move\t$4, %1\n\t" | ||
1451 | "move\t$5, %2\n\t" | ||
1452 | __MODULE_JAL(__strnlen_user_asm) | ||
1453 | "move\t%0, $2" | ||
1454 | : "=r" (res) | ||
1455 | : "r" (s), "r" (n) | ||
1456 | : "$2", "$4", "$5", __UA_t0, "$31"); | ||
1457 | } | ||
1392 | 1458 | ||
1393 | return res; | 1459 | return res; |
1394 | } | 1460 | } |