Commit f90de660678cf553f63c387945830a2e4d26dd3e

Authored by andrew hendry
Committed by David S. Miller
1 parent 5595a1a599

X25 remove bkl in facility ioctls

Signed-off-by: Andrew Hendry <andrew.hendry@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 25 additions and 23 deletions Side-by-side Diff

... ... @@ -1424,34 +1424,34 @@
1424 1424 rc = x25_subscr_ioctl(cmd, argp);
1425 1425 break;
1426 1426 case SIOCX25GFACILITIES: {
1427   - struct x25_facilities fac = x25->facilities;
1428   - lock_kernel();
1429   - rc = copy_to_user(argp, &fac,
1430   - sizeof(fac)) ? -EFAULT : 0;
1431   - unlock_kernel();
  1427 + lock_sock(sk);
  1428 + rc = copy_to_user(argp, &x25->facilities,
  1429 + sizeof(x25->facilities))
  1430 + ? -EFAULT : 0;
  1431 + release_sock(sk);
1432 1432 break;
1433 1433 }
1434 1434  
1435 1435 case SIOCX25SFACILITIES: {
1436 1436 struct x25_facilities facilities;
1437 1437 rc = -EFAULT;
1438   - lock_kernel();
1439 1438 if (copy_from_user(&facilities, argp,
1440 1439 sizeof(facilities)))
1441 1440 break;
1442 1441 rc = -EINVAL;
  1442 + lock_sock(sk);
1443 1443 if (sk->sk_state != TCP_LISTEN &&
1444 1444 sk->sk_state != TCP_CLOSE)
1445   - break;
  1445 + goto out_fac_release;
1446 1446 if (facilities.pacsize_in < X25_PS16 ||
1447 1447 facilities.pacsize_in > X25_PS4096)
1448   - break;
  1448 + goto out_fac_release;
1449 1449 if (facilities.pacsize_out < X25_PS16 ||
1450 1450 facilities.pacsize_out > X25_PS4096)
1451   - break;
  1451 + goto out_fac_release;
1452 1452 if (facilities.winsize_in < 1 ||
1453 1453 facilities.winsize_in > 127)
1454   - break;
  1454 + goto out_fac_release;
1455 1455 if (facilities.throughput) {
1456 1456 int out = facilities.throughput & 0xf0;
1457 1457 int in = facilities.throughput & 0x0f;
1458 1458  
1459 1459  
1460 1460  
1461 1461  
1462 1462  
... ... @@ -1459,27 +1459,28 @@
1459 1459 facilities.throughput |=
1460 1460 X25_DEFAULT_THROUGHPUT << 4;
1461 1461 else if (out < 0x30 || out > 0xD0)
1462   - break;
  1462 + goto out_fac_release;
1463 1463 if (!in)
1464 1464 facilities.throughput |=
1465 1465 X25_DEFAULT_THROUGHPUT;
1466 1466 else if (in < 0x03 || in > 0x0D)
1467   - break;
  1467 + goto out_fac_release;
1468 1468 }
1469 1469 if (facilities.reverse &&
1470 1470 (facilities.reverse & 0x81) != 0x81)
1471   - break;
  1471 + goto out_fac_release;
1472 1472 x25->facilities = facilities;
1473 1473 rc = 0;
1474   - unlock_kernel();
  1474 +out_fac_release:
  1475 + release_sock(sk);
1475 1476 break;
1476 1477 }
1477 1478  
1478 1479 case SIOCX25GDTEFACILITIES: {
1479   - lock_kernel();
  1480 + lock_sock(sk);
1480 1481 rc = copy_to_user(argp, &x25->dte_facilities,
1481 1482 sizeof(x25->dte_facilities));
1482   - unlock_kernel();
  1483 + release_sock(sk);
1483 1484 if (rc)
1484 1485 rc = -EFAULT;
1485 1486 break;
1486 1487  
1487 1488  
1488 1489  
1489 1490  
1490 1491  
1491 1492  
1492 1493  
... ... @@ -1488,24 +1489,25 @@
1488 1489 case SIOCX25SDTEFACILITIES: {
1489 1490 struct x25_dte_facilities dtefacs;
1490 1491 rc = -EFAULT;
1491   - lock_kernel();
1492 1492 if (copy_from_user(&dtefacs, argp, sizeof(dtefacs)))
1493 1493 break;
1494 1494 rc = -EINVAL;
  1495 + lock_sock(sk);
1495 1496 if (sk->sk_state != TCP_LISTEN &&
1496 1497 sk->sk_state != TCP_CLOSE)
1497   - break;
  1498 + goto out_dtefac_release;
1498 1499 if (dtefacs.calling_len > X25_MAX_AE_LEN)
1499   - break;
  1500 + goto out_dtefac_release;
1500 1501 if (dtefacs.calling_ae == NULL)
1501   - break;
  1502 + goto out_dtefac_release;
1502 1503 if (dtefacs.called_len > X25_MAX_AE_LEN)
1503   - break;
  1504 + goto out_dtefac_release;
1504 1505 if (dtefacs.called_ae == NULL)
1505   - break;
  1506 + goto out_dtefac_release;
1506 1507 x25->dte_facilities = dtefacs;
1507 1508 rc = 0;
1508   - unlock_kernel();
  1509 +out_dtefac_release:
  1510 + release_sock(sk);
1509 1511 break;
1510 1512 }
1511 1513