Skip to content

Commit b0d0d91

Browse files
committed
ipx: remove the BKL
This replaces all instances of lock_kernel in the IPX code with lock_sock. As far as I can tell, this is safe to do, because there is no global state that needs to be locked in IPX, and the code does not recursively take the lock or sleep indefinitely while holding it. Compile-tested only. Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: David S. Miller <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: [email protected]
1 parent 60d9f46 commit b0d0d91

File tree

2 files changed

+20
-33
lines changed

2 files changed

+20
-33
lines changed

net/ipx/Kconfig

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#
44
config IPX
55
tristate "The IPX protocol"
6-
depends on BKL # should be fixable
76
select LLC
87
---help---
98
This is support for the Novell networking protocol, IPX, commonly

net/ipx/af_ipx.c

+20-32
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#include <linux/uio.h>
4343
#include <linux/slab.h>
4444
#include <linux/skbuff.h>
45-
#include <linux/smp_lock.h>
4645
#include <linux/socket.h>
4746
#include <linux/sockios.h>
4847
#include <linux/string.h>
@@ -1299,7 +1298,7 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname,
12991298
int opt;
13001299
int rc = -EINVAL;
13011300

1302-
lock_kernel();
1301+
lock_sock(sk);
13031302
if (optlen != sizeof(int))
13041303
goto out;
13051304

@@ -1314,7 +1313,7 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname,
13141313
ipx_sk(sk)->type = opt;
13151314
rc = 0;
13161315
out:
1317-
unlock_kernel();
1316+
release_sock(sk);
13181317
return rc;
13191318
}
13201319

@@ -1326,7 +1325,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname,
13261325
int len;
13271326
int rc = -ENOPROTOOPT;
13281327

1329-
lock_kernel();
1328+
lock_sock(sk);
13301329
if (!(level == SOL_IPX && optname == IPX_TYPE))
13311330
goto out;
13321331

@@ -1347,7 +1346,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname,
13471346

13481347
rc = 0;
13491348
out:
1350-
unlock_kernel();
1349+
release_sock(sk);
13511350
return rc;
13521351
}
13531352

@@ -1396,15 +1395,15 @@ static int ipx_release(struct socket *sock)
13961395
if (!sk)
13971396
goto out;
13981397

1399-
lock_kernel();
1398+
lock_sock(sk);
14001399
if (!sock_flag(sk, SOCK_DEAD))
14011400
sk->sk_state_change(sk);
14021401

14031402
sock_set_flag(sk, SOCK_DEAD);
14041403
sock->sk = NULL;
14051404
sk_refcnt_debug_release(sk);
14061405
ipx_destroy_socket(sk);
1407-
unlock_kernel();
1406+
release_sock(sk);
14081407
out:
14091408
return 0;
14101409
}
@@ -1530,11 +1529,12 @@ static int __ipx_bind(struct socket *sock,
15301529

15311530
static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
15321531
{
1532+
struct sock *sk = sock->sk;
15331533
int rc;
15341534

1535-
lock_kernel();
1535+
lock_sock(sk);
15361536
rc = __ipx_bind(sock, uaddr, addr_len);
1537-
unlock_kernel();
1537+
release_sock(sk);
15381538

15391539
return rc;
15401540
}
@@ -1551,7 +1551,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
15511551
sk->sk_state = TCP_CLOSE;
15521552
sock->state = SS_UNCONNECTED;
15531553

1554-
lock_kernel();
1554+
lock_sock(sk);
15551555
if (addr_len != sizeof(*addr))
15561556
goto out;
15571557
addr = (struct sockaddr_ipx *)uaddr;
@@ -1598,7 +1598,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
15981598
ipxrtr_put(rt);
15991599
rc = 0;
16001600
out:
1601-
unlock_kernel();
1601+
release_sock(sk);
16021602
return rc;
16031603
}
16041604

@@ -1614,7 +1614,7 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr,
16141614

16151615
*uaddr_len = sizeof(struct sockaddr_ipx);
16161616

1617-
lock_kernel();
1617+
lock_sock(sk);
16181618
if (peer) {
16191619
rc = -ENOTCONN;
16201620
if (sk->sk_state != TCP_ESTABLISHED)
@@ -1649,19 +1649,7 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr,
16491649

16501650
rc = 0;
16511651
out:
1652-
unlock_kernel();
1653-
return rc;
1654-
}
1655-
1656-
static unsigned int ipx_datagram_poll(struct file *file, struct socket *sock,
1657-
poll_table *wait)
1658-
{
1659-
int rc;
1660-
1661-
lock_kernel();
1662-
rc = datagram_poll(file, sock, wait);
1663-
unlock_kernel();
1664-
1652+
release_sock(sk);
16651653
return rc;
16661654
}
16671655

@@ -1736,7 +1724,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
17361724
int rc = -EINVAL;
17371725
int flags = msg->msg_flags;
17381726

1739-
lock_kernel();
1727+
lock_sock(sk);
17401728
/* Socket gets bound below anyway */
17411729
/* if (sk->sk_zapped)
17421730
return -EIO; */ /* Socket not bound */
@@ -1788,7 +1776,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
17881776
if (rc >= 0)
17891777
rc = len;
17901778
out:
1791-
unlock_kernel();
1779+
release_sock(sk);
17921780
return rc;
17931781
}
17941782

@@ -1803,7 +1791,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
18031791
struct sk_buff *skb;
18041792
int copied, rc;
18051793

1806-
lock_kernel();
1794+
lock_sock(sk);
18071795
/* put the autobinding in */
18081796
if (!ipxs->port) {
18091797
struct sockaddr_ipx uaddr;
@@ -1862,7 +1850,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
18621850
out_free:
18631851
skb_free_datagram(sk, skb);
18641852
out:
1865-
unlock_kernel();
1853+
release_sock(sk);
18661854
return rc;
18671855
}
18681856

@@ -1874,7 +1862,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
18741862
struct sock *sk = sock->sk;
18751863
void __user *argp = (void __user *)arg;
18761864

1877-
lock_kernel();
1865+
lock_sock(sk);
18781866
switch (cmd) {
18791867
case TIOCOUTQ:
18801868
amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
@@ -1937,7 +1925,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
19371925
rc = -ENOIOCTLCMD;
19381926
break;
19391927
}
1940-
unlock_kernel();
1928+
release_sock(sk);
19411929

19421930
return rc;
19431931
}
@@ -1984,7 +1972,7 @@ static const struct proto_ops ipx_dgram_ops = {
19841972
.socketpair = sock_no_socketpair,
19851973
.accept = sock_no_accept,
19861974
.getname = ipx_getname,
1987-
.poll = ipx_datagram_poll,
1975+
.poll = datagram_poll,
19881976
.ioctl = ipx_ioctl,
19891977
#ifdef CONFIG_COMPAT
19901978
.compat_ioctl = ipx_compat_ioctl,

0 commit comments

Comments
 (0)