Commit 60d9f461 authored by Arnd Bergmann's avatar Arnd Bergmann

appletalk: remove the BKL

This changes appletalk to use lock_sock instead of
lock_kernel for serialization. I tried to make sure
that we don't hold the socket lock during sleeping
functions, but I did not try to prove whether the
locks are necessary in the first place.

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: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
parent 77b22836
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# #
config ATALK config ATALK
tristate "Appletalk protocol support" tristate "Appletalk protocol support"
depends on BKL # waiting to be removed from net/appletalk/ddp.c
select LLC select LLC
---help--- ---help---
AppleTalk is the protocol that Apple computers can use to communicate AppleTalk is the protocol that Apple computers can use to communicate
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/smp_lock.h>
#include <linux/termios.h> /* For TIOCOUTQ/INQ */ #include <linux/termios.h> /* For TIOCOUTQ/INQ */
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -1052,13 +1051,13 @@ static int atalk_release(struct socket *sock) ...@@ -1052,13 +1051,13 @@ static int atalk_release(struct socket *sock)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
lock_kernel(); lock_sock(sk);
if (sk) { if (sk) {
sock_orphan(sk); sock_orphan(sk);
sock->sk = NULL; sock->sk = NULL;
atalk_destroy_socket(sk); atalk_destroy_socket(sk);
} }
unlock_kernel(); release_sock(sk);
return 0; return 0;
} }
...@@ -1143,7 +1142,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -1143,7 +1142,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
if (addr->sat_family != AF_APPLETALK) if (addr->sat_family != AF_APPLETALK)
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
lock_kernel(); lock_sock(sk);
if (addr->sat_addr.s_net == htons(ATADDR_ANYNET)) { if (addr->sat_addr.s_net == htons(ATADDR_ANYNET)) {
struct atalk_addr *ap = atalk_find_primary(); struct atalk_addr *ap = atalk_find_primary();
...@@ -1179,7 +1178,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -1179,7 +1178,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
sock_reset_flag(sk, SOCK_ZAPPED); sock_reset_flag(sk, SOCK_ZAPPED);
err = 0; err = 0;
out: out:
unlock_kernel(); release_sock(sk);
return err; return err;
} }
...@@ -1215,7 +1214,7 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1215,7 +1214,7 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr,
#endif #endif
} }
lock_kernel(); lock_sock(sk);
err = -EBUSY; err = -EBUSY;
if (sock_flag(sk, SOCK_ZAPPED)) if (sock_flag(sk, SOCK_ZAPPED))
if (atalk_autobind(sk) < 0) if (atalk_autobind(sk) < 0)
...@@ -1233,7 +1232,7 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1233,7 +1232,7 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr,
sk->sk_state = TCP_ESTABLISHED; sk->sk_state = TCP_ESTABLISHED;
err = 0; err = 0;
out: out:
unlock_kernel(); release_sock(sk);
return err; return err;
} }
...@@ -1249,7 +1248,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -1249,7 +1248,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
struct atalk_sock *at = at_sk(sk); struct atalk_sock *at = at_sk(sk);
int err; int err;
lock_kernel(); lock_sock(sk);
err = -ENOBUFS; err = -ENOBUFS;
if (sock_flag(sk, SOCK_ZAPPED)) if (sock_flag(sk, SOCK_ZAPPED))
if (atalk_autobind(sk) < 0) if (atalk_autobind(sk) < 0)
...@@ -1277,17 +1276,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -1277,17 +1276,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
memcpy(uaddr, &sat, sizeof(sat)); memcpy(uaddr, &sat, sizeof(sat));
out: out:
unlock_kernel(); release_sock(sk);
return err;
}
static unsigned int atalk_poll(struct file *file, struct socket *sock,
poll_table *wait)
{
int err;
lock_kernel();
err = datagram_poll(file, sock, wait);
unlock_kernel();
return err; return err;
} }
...@@ -1596,7 +1585,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr ...@@ -1596,7 +1585,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
if (len > DDP_MAXSZ) if (len > DDP_MAXSZ)
return -EMSGSIZE; return -EMSGSIZE;
lock_kernel(); lock_sock(sk);
if (usat) { if (usat) {
err = -EBUSY; err = -EBUSY;
if (sock_flag(sk, SOCK_ZAPPED)) if (sock_flag(sk, SOCK_ZAPPED))
...@@ -1651,7 +1640,9 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr ...@@ -1651,7 +1640,9 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
sk, size, dev->name); sk, size, dev->name);
size += dev->hard_header_len; size += dev->hard_header_len;
release_sock(sk);
skb = sock_alloc_send_skb(sk, size, (flags & MSG_DONTWAIT), &err); skb = sock_alloc_send_skb(sk, size, (flags & MSG_DONTWAIT), &err);
lock_sock(sk);
if (!skb) if (!skb)
goto out; goto out;
...@@ -1738,7 +1729,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr ...@@ -1738,7 +1729,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
SOCK_DEBUG(sk, "SK %p: Done write (%Zd).\n", sk, len); SOCK_DEBUG(sk, "SK %p: Done write (%Zd).\n", sk, len);
out: out:
unlock_kernel(); release_sock(sk);
return err ? : len; return err ? : len;
} }
...@@ -1753,9 +1744,10 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr ...@@ -1753,9 +1744,10 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
int err = 0; int err = 0;
struct sk_buff *skb; struct sk_buff *skb;
lock_kernel();
skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
flags & MSG_DONTWAIT, &err); flags & MSG_DONTWAIT, &err);
lock_sock(sk);
if (!skb) if (!skb)
goto out; goto out;
...@@ -1787,7 +1779,7 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr ...@@ -1787,7 +1779,7 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
skb_free_datagram(sk, skb); /* Free the datagram. */ skb_free_datagram(sk, skb); /* Free the datagram. */
out: out:
unlock_kernel(); release_sock(sk);
return err ? : copied; return err ? : copied;
} }
...@@ -1887,7 +1879,7 @@ static const struct proto_ops atalk_dgram_ops = { ...@@ -1887,7 +1879,7 @@ static const struct proto_ops atalk_dgram_ops = {
.socketpair = sock_no_socketpair, .socketpair = sock_no_socketpair,
.accept = sock_no_accept, .accept = sock_no_accept,
.getname = atalk_getname, .getname = atalk_getname,
.poll = atalk_poll, .poll = datagram_poll,
.ioctl = atalk_ioctl, .ioctl = atalk_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = atalk_compat_ioctl, .compat_ioctl = atalk_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