diff options
author | andrew hendry <andrew.hendry@gmail.com> | 2010-11-18 08:20:57 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-19 15:40:00 -0500 |
commit | 70be998c2b44f942f11383496622500136816acb (patch) | |
tree | 910e441e8b8561ab987680c9a8e52eabe9973cd1 /net/x25 | |
parent | c26aed40f4fd18f86bcc6aba557cab700b129b73 (diff) |
X25: pushdown bkl in ioctls
Push down the bkl in the ioctls so they can be removed one at a time.
Signed-off-by: Andrew Hendry <andrew.hendry@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/x25')
-rw-r--r-- | net/x25/af_x25.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index f7af98dff409..c99029bc411c 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c | |||
@@ -1357,14 +1357,16 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1357 | void __user *argp = (void __user *)arg; | 1357 | void __user *argp = (void __user *)arg; |
1358 | int rc; | 1358 | int rc; |
1359 | 1359 | ||
1360 | lock_kernel(); | ||
1361 | switch (cmd) { | 1360 | switch (cmd) { |
1362 | case TIOCOUTQ: { | 1361 | case TIOCOUTQ: { |
1363 | int amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk); | 1362 | int amount; |
1364 | 1363 | ||
1364 | lock_kernel(); | ||
1365 | amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk); | ||
1365 | if (amount < 0) | 1366 | if (amount < 0) |
1366 | amount = 0; | 1367 | amount = 0; |
1367 | rc = put_user(amount, (unsigned int __user *)argp); | 1368 | rc = put_user(amount, (unsigned int __user *)argp); |
1369 | unlock_kernel(); | ||
1368 | break; | 1370 | break; |
1369 | } | 1371 | } |
1370 | 1372 | ||
@@ -1375,23 +1377,29 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1375 | * These two are safe on a single CPU system as | 1377 | * These two are safe on a single CPU system as |
1376 | * only user tasks fiddle here | 1378 | * only user tasks fiddle here |
1377 | */ | 1379 | */ |
1380 | lock_kernel(); | ||
1378 | if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) | 1381 | if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) |
1379 | amount = skb->len; | 1382 | amount = skb->len; |
1380 | rc = put_user(amount, (unsigned int __user *)argp); | 1383 | rc = put_user(amount, (unsigned int __user *)argp); |
1384 | unlock_kernel(); | ||
1381 | break; | 1385 | break; |
1382 | } | 1386 | } |
1383 | 1387 | ||
1384 | case SIOCGSTAMP: | 1388 | case SIOCGSTAMP: |
1385 | rc = -EINVAL; | 1389 | rc = -EINVAL; |
1390 | lock_kernel(); | ||
1386 | if (sk) | 1391 | if (sk) |
1387 | rc = sock_get_timestamp(sk, | 1392 | rc = sock_get_timestamp(sk, |
1388 | (struct timeval __user *)argp); | 1393 | (struct timeval __user *)argp); |
1394 | unlock_kernel(); | ||
1389 | break; | 1395 | break; |
1390 | case SIOCGSTAMPNS: | 1396 | case SIOCGSTAMPNS: |
1391 | rc = -EINVAL; | 1397 | rc = -EINVAL; |
1398 | lock_kernel(); | ||
1392 | if (sk) | 1399 | if (sk) |
1393 | rc = sock_get_timestampns(sk, | 1400 | rc = sock_get_timestampns(sk, |
1394 | (struct timespec __user *)argp); | 1401 | (struct timespec __user *)argp); |
1402 | unlock_kernel(); | ||
1395 | break; | 1403 | break; |
1396 | case SIOCGIFADDR: | 1404 | case SIOCGIFADDR: |
1397 | case SIOCSIFADDR: | 1405 | case SIOCSIFADDR: |
@@ -1410,27 +1418,36 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1410 | rc = -EPERM; | 1418 | rc = -EPERM; |
1411 | if (!capable(CAP_NET_ADMIN)) | 1419 | if (!capable(CAP_NET_ADMIN)) |
1412 | break; | 1420 | break; |
1421 | lock_kernel(); | ||
1413 | rc = x25_route_ioctl(cmd, argp); | 1422 | rc = x25_route_ioctl(cmd, argp); |
1423 | unlock_kernel(); | ||
1414 | break; | 1424 | break; |
1415 | case SIOCX25GSUBSCRIP: | 1425 | case SIOCX25GSUBSCRIP: |
1426 | lock_kernel(); | ||
1416 | rc = x25_subscr_ioctl(cmd, argp); | 1427 | rc = x25_subscr_ioctl(cmd, argp); |
1428 | unlock_kernel(); | ||
1417 | break; | 1429 | break; |
1418 | case SIOCX25SSUBSCRIP: | 1430 | case SIOCX25SSUBSCRIP: |
1419 | rc = -EPERM; | 1431 | rc = -EPERM; |
1420 | if (!capable(CAP_NET_ADMIN)) | 1432 | if (!capable(CAP_NET_ADMIN)) |
1421 | break; | 1433 | break; |
1434 | lock_kernel(); | ||
1422 | rc = x25_subscr_ioctl(cmd, argp); | 1435 | rc = x25_subscr_ioctl(cmd, argp); |
1436 | unlock_kernel(); | ||
1423 | break; | 1437 | break; |
1424 | case SIOCX25GFACILITIES: { | 1438 | case SIOCX25GFACILITIES: { |
1425 | struct x25_facilities fac = x25->facilities; | 1439 | struct x25_facilities fac = x25->facilities; |
1440 | lock_kernel(); | ||
1426 | rc = copy_to_user(argp, &fac, | 1441 | rc = copy_to_user(argp, &fac, |
1427 | sizeof(fac)) ? -EFAULT : 0; | 1442 | sizeof(fac)) ? -EFAULT : 0; |
1443 | unlock_kernel(); | ||
1428 | break; | 1444 | break; |
1429 | } | 1445 | } |
1430 | 1446 | ||
1431 | case SIOCX25SFACILITIES: { | 1447 | case SIOCX25SFACILITIES: { |
1432 | struct x25_facilities facilities; | 1448 | struct x25_facilities facilities; |
1433 | rc = -EFAULT; | 1449 | rc = -EFAULT; |
1450 | lock_kernel(); | ||
1434 | if (copy_from_user(&facilities, argp, | 1451 | if (copy_from_user(&facilities, argp, |
1435 | sizeof(facilities))) | 1452 | sizeof(facilities))) |
1436 | break; | 1453 | break; |
@@ -1466,12 +1483,15 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1466 | break; | 1483 | break; |
1467 | x25->facilities = facilities; | 1484 | x25->facilities = facilities; |
1468 | rc = 0; | 1485 | rc = 0; |
1486 | unlock_kernel(); | ||
1469 | break; | 1487 | break; |
1470 | } | 1488 | } |
1471 | 1489 | ||
1472 | case SIOCX25GDTEFACILITIES: { | 1490 | case SIOCX25GDTEFACILITIES: { |
1491 | lock_kernel(); | ||
1473 | rc = copy_to_user(argp, &x25->dte_facilities, | 1492 | rc = copy_to_user(argp, &x25->dte_facilities, |
1474 | sizeof(x25->dte_facilities)); | 1493 | sizeof(x25->dte_facilities)); |
1494 | unlock_kernel(); | ||
1475 | if (rc) | 1495 | if (rc) |
1476 | rc = -EFAULT; | 1496 | rc = -EFAULT; |
1477 | break; | 1497 | break; |
@@ -1480,6 +1500,7 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1480 | case SIOCX25SDTEFACILITIES: { | 1500 | case SIOCX25SDTEFACILITIES: { |
1481 | struct x25_dte_facilities dtefacs; | 1501 | struct x25_dte_facilities dtefacs; |
1482 | rc = -EFAULT; | 1502 | rc = -EFAULT; |
1503 | lock_kernel(); | ||
1483 | if (copy_from_user(&dtefacs, argp, sizeof(dtefacs))) | 1504 | if (copy_from_user(&dtefacs, argp, sizeof(dtefacs))) |
1484 | break; | 1505 | break; |
1485 | rc = -EINVAL; | 1506 | rc = -EINVAL; |
@@ -1496,13 +1517,16 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1496 | break; | 1517 | break; |
1497 | x25->dte_facilities = dtefacs; | 1518 | x25->dte_facilities = dtefacs; |
1498 | rc = 0; | 1519 | rc = 0; |
1520 | unlock_kernel(); | ||
1499 | break; | 1521 | break; |
1500 | } | 1522 | } |
1501 | 1523 | ||
1502 | case SIOCX25GCALLUSERDATA: { | 1524 | case SIOCX25GCALLUSERDATA: { |
1503 | struct x25_calluserdata cud = x25->calluserdata; | 1525 | struct x25_calluserdata cud = x25->calluserdata; |
1526 | lock_kernel(); | ||
1504 | rc = copy_to_user(argp, &cud, | 1527 | rc = copy_to_user(argp, &cud, |
1505 | sizeof(cud)) ? -EFAULT : 0; | 1528 | sizeof(cud)) ? -EFAULT : 0; |
1529 | unlock_kernel(); | ||
1506 | break; | 1530 | break; |
1507 | } | 1531 | } |
1508 | 1532 | ||
@@ -1510,6 +1534,7 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1510 | struct x25_calluserdata calluserdata; | 1534 | struct x25_calluserdata calluserdata; |
1511 | 1535 | ||
1512 | rc = -EFAULT; | 1536 | rc = -EFAULT; |
1537 | lock_kernel(); | ||
1513 | if (copy_from_user(&calluserdata, argp, | 1538 | if (copy_from_user(&calluserdata, argp, |
1514 | sizeof(calluserdata))) | 1539 | sizeof(calluserdata))) |
1515 | break; | 1540 | break; |
@@ -1517,24 +1542,29 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1517 | if (calluserdata.cudlength > X25_MAX_CUD_LEN) | 1542 | if (calluserdata.cudlength > X25_MAX_CUD_LEN) |
1518 | break; | 1543 | break; |
1519 | x25->calluserdata = calluserdata; | 1544 | x25->calluserdata = calluserdata; |
1545 | unlock_kernel(); | ||
1520 | rc = 0; | 1546 | rc = 0; |
1521 | break; | 1547 | break; |
1522 | } | 1548 | } |
1523 | 1549 | ||
1524 | case SIOCX25GCAUSEDIAG: { | 1550 | case SIOCX25GCAUSEDIAG: { |
1525 | struct x25_causediag causediag; | 1551 | struct x25_causediag causediag; |
1552 | lock_kernel(); | ||
1526 | causediag = x25->causediag; | 1553 | causediag = x25->causediag; |
1527 | rc = copy_to_user(argp, &causediag, | 1554 | rc = copy_to_user(argp, &causediag, |
1528 | sizeof(causediag)) ? -EFAULT : 0; | 1555 | sizeof(causediag)) ? -EFAULT : 0; |
1556 | unlock_kernel(); | ||
1529 | break; | 1557 | break; |
1530 | } | 1558 | } |
1531 | 1559 | ||
1532 | case SIOCX25SCAUSEDIAG: { | 1560 | case SIOCX25SCAUSEDIAG: { |
1533 | struct x25_causediag causediag; | 1561 | struct x25_causediag causediag; |
1534 | rc = -EFAULT; | 1562 | rc = -EFAULT; |
1563 | lock_kernel(); | ||
1535 | if (copy_from_user(&causediag, argp, sizeof(causediag))) | 1564 | if (copy_from_user(&causediag, argp, sizeof(causediag))) |
1536 | break; | 1565 | break; |
1537 | x25->causediag = causediag; | 1566 | x25->causediag = causediag; |
1567 | unlock_kernel(); | ||
1538 | rc = 0; | 1568 | rc = 0; |
1539 | break; | 1569 | break; |
1540 | 1570 | ||
@@ -1543,6 +1573,7 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1543 | case SIOCX25SCUDMATCHLEN: { | 1573 | case SIOCX25SCUDMATCHLEN: { |
1544 | struct x25_subaddr sub_addr; | 1574 | struct x25_subaddr sub_addr; |
1545 | rc = -EINVAL; | 1575 | rc = -EINVAL; |
1576 | lock_kernel(); | ||
1546 | if(sk->sk_state != TCP_CLOSE) | 1577 | if(sk->sk_state != TCP_CLOSE) |
1547 | break; | 1578 | break; |
1548 | rc = -EFAULT; | 1579 | rc = -EFAULT; |
@@ -1553,21 +1584,25 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1553 | if(sub_addr.cudmatchlength > X25_MAX_CUD_LEN) | 1584 | if(sub_addr.cudmatchlength > X25_MAX_CUD_LEN) |
1554 | break; | 1585 | break; |
1555 | x25->cudmatchlength = sub_addr.cudmatchlength; | 1586 | x25->cudmatchlength = sub_addr.cudmatchlength; |
1587 | unlock_kernel(); | ||
1556 | rc = 0; | 1588 | rc = 0; |
1557 | break; | 1589 | break; |
1558 | } | 1590 | } |
1559 | 1591 | ||
1560 | case SIOCX25CALLACCPTAPPRV: { | 1592 | case SIOCX25CALLACCPTAPPRV: { |
1561 | rc = -EINVAL; | 1593 | rc = -EINVAL; |
1594 | lock_kernel(); | ||
1562 | if (sk->sk_state != TCP_CLOSE) | 1595 | if (sk->sk_state != TCP_CLOSE) |
1563 | break; | 1596 | break; |
1564 | clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags); | 1597 | clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags); |
1598 | unlock_kernel(); | ||
1565 | rc = 0; | 1599 | rc = 0; |
1566 | break; | 1600 | break; |
1567 | } | 1601 | } |
1568 | 1602 | ||
1569 | case SIOCX25SENDCALLACCPT: { | 1603 | case SIOCX25SENDCALLACCPT: { |
1570 | rc = -EINVAL; | 1604 | rc = -EINVAL; |
1605 | lock_kernel(); | ||
1571 | if (sk->sk_state != TCP_ESTABLISHED) | 1606 | if (sk->sk_state != TCP_ESTABLISHED) |
1572 | break; | 1607 | break; |
1573 | /* must call accptapprv above */ | 1608 | /* must call accptapprv above */ |
@@ -1575,6 +1610,7 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1575 | break; | 1610 | break; |
1576 | x25_write_internal(sk, X25_CALL_ACCEPTED); | 1611 | x25_write_internal(sk, X25_CALL_ACCEPTED); |
1577 | x25->state = X25_STATE_3; | 1612 | x25->state = X25_STATE_3; |
1613 | unlock_kernel(); | ||
1578 | rc = 0; | 1614 | rc = 0; |
1579 | break; | 1615 | break; |
1580 | } | 1616 | } |
@@ -1583,7 +1619,6 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1583 | rc = -ENOIOCTLCMD; | 1619 | rc = -ENOIOCTLCMD; |
1584 | break; | 1620 | break; |
1585 | } | 1621 | } |
1586 | unlock_kernel(); | ||
1587 | 1622 | ||
1588 | return rc; | 1623 | return rc; |
1589 | } | 1624 | } |