diff options
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r-- | net/unix/af_unix.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 01625ccc3ae6..29fc8bee9702 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -80,6 +80,8 @@ | |||
80 | * with BSD names. | 80 | * with BSD names. |
81 | */ | 81 | */ |
82 | 82 | ||
83 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
84 | |||
83 | #include <linux/module.h> | 85 | #include <linux/module.h> |
84 | #include <linux/kernel.h> | 86 | #include <linux/kernel.h> |
85 | #include <linux/signal.h> | 87 | #include <linux/signal.h> |
@@ -366,7 +368,7 @@ static void unix_sock_destructor(struct sock *sk) | |||
366 | WARN_ON(!sk_unhashed(sk)); | 368 | WARN_ON(!sk_unhashed(sk)); |
367 | WARN_ON(sk->sk_socket); | 369 | WARN_ON(sk->sk_socket); |
368 | if (!sock_flag(sk, SOCK_DEAD)) { | 370 | if (!sock_flag(sk, SOCK_DEAD)) { |
369 | printk(KERN_INFO "Attempt to release alive unix socket: %p\n", sk); | 371 | pr_info("Attempt to release alive unix socket: %p\n", sk); |
370 | return; | 372 | return; |
371 | } | 373 | } |
372 | 374 | ||
@@ -378,7 +380,7 @@ static void unix_sock_destructor(struct sock *sk) | |||
378 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); | 380 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); |
379 | local_bh_enable(); | 381 | local_bh_enable(); |
380 | #ifdef UNIX_REFCNT_DEBUG | 382 | #ifdef UNIX_REFCNT_DEBUG |
381 | printk(KERN_DEBUG "UNIX %p is destroyed, %ld are still alive.\n", sk, | 383 | pr_debug("UNIX %p is destroyed, %ld are still alive.\n", sk, |
382 | atomic_long_read(&unix_nr_socks)); | 384 | atomic_long_read(&unix_nr_socks)); |
383 | #endif | 385 | #endif |
384 | } | 386 | } |
@@ -530,13 +532,17 @@ static int unix_seqpacket_sendmsg(struct kiocb *, struct socket *, | |||
530 | static int unix_seqpacket_recvmsg(struct kiocb *, struct socket *, | 532 | static int unix_seqpacket_recvmsg(struct kiocb *, struct socket *, |
531 | struct msghdr *, size_t, int); | 533 | struct msghdr *, size_t, int); |
532 | 534 | ||
533 | static void unix_set_peek_off(struct sock *sk, int val) | 535 | static int unix_set_peek_off(struct sock *sk, int val) |
534 | { | 536 | { |
535 | struct unix_sock *u = unix_sk(sk); | 537 | struct unix_sock *u = unix_sk(sk); |
536 | 538 | ||
537 | mutex_lock(&u->readlock); | 539 | if (mutex_lock_interruptible(&u->readlock)) |
540 | return -EINTR; | ||
541 | |||
538 | sk->sk_peek_off = val; | 542 | sk->sk_peek_off = val; |
539 | mutex_unlock(&u->readlock); | 543 | mutex_unlock(&u->readlock); |
544 | |||
545 | return 0; | ||
540 | } | 546 | } |
541 | 547 | ||
542 | 548 | ||
@@ -714,7 +720,9 @@ static int unix_autobind(struct socket *sock) | |||
714 | int err; | 720 | int err; |
715 | unsigned int retries = 0; | 721 | unsigned int retries = 0; |
716 | 722 | ||
717 | mutex_lock(&u->readlock); | 723 | err = mutex_lock_interruptible(&u->readlock); |
724 | if (err) | ||
725 | return err; | ||
718 | 726 | ||
719 | err = 0; | 727 | err = 0; |
720 | if (u->addr) | 728 | if (u->addr) |
@@ -873,7 +881,9 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
873 | goto out; | 881 | goto out; |
874 | addr_len = err; | 882 | addr_len = err; |
875 | 883 | ||
876 | mutex_lock(&u->readlock); | 884 | err = mutex_lock_interruptible(&u->readlock); |
885 | if (err) | ||
886 | goto out; | ||
877 | 887 | ||
878 | err = -EINVAL; | 888 | err = -EINVAL; |
879 | if (u->addr) | 889 | if (u->addr) |
@@ -1440,7 +1450,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1440 | struct sock *sk = sock->sk; | 1450 | struct sock *sk = sock->sk; |
1441 | struct net *net = sock_net(sk); | 1451 | struct net *net = sock_net(sk); |
1442 | struct unix_sock *u = unix_sk(sk); | 1452 | struct unix_sock *u = unix_sk(sk); |
1443 | struct sockaddr_un *sunaddr = msg->msg_name; | 1453 | DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, msg->msg_name); |
1444 | struct sock *other = NULL; | 1454 | struct sock *other = NULL; |
1445 | int namelen = 0; /* fake GCC */ | 1455 | int namelen = 0; /* fake GCC */ |
1446 | int err; | 1456 | int err; |
@@ -1902,7 +1912,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1902 | struct scm_cookie tmp_scm; | 1912 | struct scm_cookie tmp_scm; |
1903 | struct sock *sk = sock->sk; | 1913 | struct sock *sk = sock->sk; |
1904 | struct unix_sock *u = unix_sk(sk); | 1914 | struct unix_sock *u = unix_sk(sk); |
1905 | struct sockaddr_un *sunaddr = msg->msg_name; | 1915 | DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, msg->msg_name); |
1906 | int copied = 0; | 1916 | int copied = 0; |
1907 | int check_creds = 0; | 1917 | int check_creds = 0; |
1908 | int target; | 1918 | int target; |
@@ -2433,8 +2443,7 @@ static int __init af_unix_init(void) | |||
2433 | 2443 | ||
2434 | rc = proto_register(&unix_proto, 1); | 2444 | rc = proto_register(&unix_proto, 1); |
2435 | if (rc != 0) { | 2445 | if (rc != 0) { |
2436 | printk(KERN_CRIT "%s: Cannot create unix_sock SLAB cache!\n", | 2446 | pr_crit("%s: Cannot create unix_sock SLAB cache!\n", __func__); |
2437 | __func__); | ||
2438 | goto out; | 2447 | goto out; |
2439 | } | 2448 | } |
2440 | 2449 | ||