Commit b0d0d915 authored by Arnd Bergmann's avatar Arnd Bergmann

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: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: netdev@vger.kernel.org
parent 60d9f461
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# #
config IPX config IPX
tristate "The IPX protocol" tristate "The IPX protocol"
depends on BKL # should be fixable
select LLC select LLC
---help--- ---help---
This is support for the Novell networking protocol, IPX, commonly This is support for the Novell networking protocol, IPX, commonly
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include <linux/uio.h> #include <linux/uio.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/smp_lock.h>
#include <linux/socket.h> #include <linux/socket.h>
#include <linux/sockios.h> #include <linux/sockios.h>
#include <linux/string.h> #include <linux/string.h>
...@@ -1299,7 +1298,7 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname, ...@@ -1299,7 +1298,7 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname,
int opt; int opt;
int rc = -EINVAL; int rc = -EINVAL;
lock_kernel(); lock_sock(sk);
if (optlen != sizeof(int)) if (optlen != sizeof(int))
goto out; goto out;
...@@ -1314,7 +1313,7 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname, ...@@ -1314,7 +1313,7 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname,
ipx_sk(sk)->type = opt; ipx_sk(sk)->type = opt;
rc = 0; rc = 0;
out: out:
unlock_kernel(); release_sock(sk);
return rc; return rc;
} }
...@@ -1326,7 +1325,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname, ...@@ -1326,7 +1325,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname,
int len; int len;
int rc = -ENOPROTOOPT; int rc = -ENOPROTOOPT;
lock_kernel(); lock_sock(sk);
if (!(level == SOL_IPX && optname == IPX_TYPE)) if (!(level == SOL_IPX && optname == IPX_TYPE))
goto out; goto out;
...@@ -1347,7 +1346,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname, ...@@ -1347,7 +1346,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname,
rc = 0; rc = 0;
out: out:
unlock_kernel(); release_sock(sk);
return rc; return rc;
} }
...@@ -1396,7 +1395,7 @@ static int ipx_release(struct socket *sock) ...@@ -1396,7 +1395,7 @@ static int ipx_release(struct socket *sock)
if (!sk) if (!sk)
goto out; goto out;
lock_kernel(); lock_sock(sk);
if (!sock_flag(sk, SOCK_DEAD)) if (!sock_flag(sk, SOCK_DEAD))
sk->sk_state_change(sk); sk->sk_state_change(sk);
...@@ -1404,7 +1403,7 @@ static int ipx_release(struct socket *sock) ...@@ -1404,7 +1403,7 @@ static int ipx_release(struct socket *sock)
sock->sk = NULL; sock->sk = NULL;
sk_refcnt_debug_release(sk); sk_refcnt_debug_release(sk);
ipx_destroy_socket(sk); ipx_destroy_socket(sk);
unlock_kernel(); release_sock(sk);
out: out:
return 0; return 0;
} }
...@@ -1530,11 +1529,12 @@ static int __ipx_bind(struct socket *sock, ...@@ -1530,11 +1529,12 @@ static int __ipx_bind(struct socket *sock,
static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{ {
struct sock *sk = sock->sk;
int rc; int rc;
lock_kernel(); lock_sock(sk);
rc = __ipx_bind(sock, uaddr, addr_len); rc = __ipx_bind(sock, uaddr, addr_len);
unlock_kernel(); release_sock(sk);
return rc; return rc;
} }
...@@ -1551,7 +1551,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1551,7 +1551,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
sk->sk_state = TCP_CLOSE; sk->sk_state = TCP_CLOSE;
sock->state = SS_UNCONNECTED; sock->state = SS_UNCONNECTED;
lock_kernel(); lock_sock(sk);
if (addr_len != sizeof(*addr)) if (addr_len != sizeof(*addr))
goto out; goto out;
addr = (struct sockaddr_ipx *)uaddr; addr = (struct sockaddr_ipx *)uaddr;
...@@ -1598,7 +1598,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1598,7 +1598,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
ipxrtr_put(rt); ipxrtr_put(rt);
rc = 0; rc = 0;
out: out:
unlock_kernel(); release_sock(sk);
return rc; return rc;
} }
...@@ -1614,7 +1614,7 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -1614,7 +1614,7 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr,
*uaddr_len = sizeof(struct sockaddr_ipx); *uaddr_len = sizeof(struct sockaddr_ipx);
lock_kernel(); lock_sock(sk);
if (peer) { if (peer) {
rc = -ENOTCONN; rc = -ENOTCONN;
if (sk->sk_state != TCP_ESTABLISHED) if (sk->sk_state != TCP_ESTABLISHED)
...@@ -1649,19 +1649,7 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -1649,19 +1649,7 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr,
rc = 0; rc = 0;
out: out:
unlock_kernel(); release_sock(sk);
return rc;
}
static unsigned int ipx_datagram_poll(struct file *file, struct socket *sock,
poll_table *wait)
{
int rc;
lock_kernel();
rc = datagram_poll(file, sock, wait);
unlock_kernel();
return rc; return rc;
} }
...@@ -1736,7 +1724,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1736,7 +1724,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
int rc = -EINVAL; int rc = -EINVAL;
int flags = msg->msg_flags; int flags = msg->msg_flags;
lock_kernel(); lock_sock(sk);
/* Socket gets bound below anyway */ /* Socket gets bound below anyway */
/* if (sk->sk_zapped) /* if (sk->sk_zapped)
return -EIO; */ /* Socket not bound */ return -EIO; */ /* Socket not bound */
...@@ -1788,7 +1776,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1788,7 +1776,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
if (rc >= 0) if (rc >= 0)
rc = len; rc = len;
out: out:
unlock_kernel(); release_sock(sk);
return rc; return rc;
} }
...@@ -1803,7 +1791,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1803,7 +1791,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
struct sk_buff *skb; struct sk_buff *skb;
int copied, rc; int copied, rc;
lock_kernel(); lock_sock(sk);
/* put the autobinding in */ /* put the autobinding in */
if (!ipxs->port) { if (!ipxs->port) {
struct sockaddr_ipx uaddr; struct sockaddr_ipx uaddr;
...@@ -1862,7 +1850,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1862,7 +1850,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
out_free: out_free:
skb_free_datagram(sk, skb); skb_free_datagram(sk, skb);
out: out:
unlock_kernel(); release_sock(sk);
return rc; return rc;
} }
...@@ -1874,7 +1862,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1874,7 +1862,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
lock_kernel(); lock_sock(sk);
switch (cmd) { switch (cmd) {
case TIOCOUTQ: case TIOCOUTQ:
amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk); 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) ...@@ -1937,7 +1925,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
rc = -ENOIOCTLCMD; rc = -ENOIOCTLCMD;
break; break;
} }
unlock_kernel(); release_sock(sk);
return rc; return rc;
} }
...@@ -1984,7 +1972,7 @@ static const struct proto_ops ipx_dgram_ops = { ...@@ -1984,7 +1972,7 @@ static const struct proto_ops ipx_dgram_ops = {
.socketpair = sock_no_socketpair, .socketpair = sock_no_socketpair,
.accept = sock_no_accept, .accept = sock_no_accept,
.getname = ipx_getname, .getname = ipx_getname,
.poll = ipx_datagram_poll, .poll = datagram_poll,
.ioctl = ipx_ioctl, .ioctl = ipx_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = ipx_compat_ioctl, .compat_ioctl = ipx_compat_ioctl,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment