aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/af_unix.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-21 16:36:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-21 16:36:41 -0400
commite2a0883e4071237d09b604a342c28b96b44a04b3 (patch)
treeaa56f4d376b5eb1c32358c19c2669c2a94e0e1fd /net/unix/af_unix.c
parent3a990a52f9f25f45469e272017a31e7a3fda60ed (diff)
parent07c0c5d8b8c122b2f2df9ee574ac3083daefc981 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs pile 1 from Al Viro: "This is _not_ all; in particular, Miklos' and Jan's stuff is not there yet." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (64 commits) ext4: initialization of ext4_li_mtx needs to be done earlier debugfs-related mode_t whack-a-mole hfsplus: add an ioctl to bless files hfsplus: change finder_info to u32 hfsplus: initialise userflags qnx4: new helper - try_extent() qnx4: get rid of qnx4_bread/qnx4_getblk take removal of PF_FORKNOEXEC to flush_old_exec() trim includes in inode.c um: uml_dup_mmap() relies on ->mmap_sem being held, but activate_mm() doesn't hold it um: embed ->stub_pages[] into mmu_context gadgetfs: list_for_each_safe() misuse ocfs2: fix leaks on failure exits in module_init ecryptfs: make register_filesystem() the last potential failure exit ntfs: forgets to unregister sysctls on register_filesystem() failure logfs: missing cleanup on register_filesystem() failure jfs: mising cleanup on register_filesystem() failure make configfs_pin_fs() return root dentry on success configfs: configfs_create_dir() has parent dentry in dentry->d_parent configfs: sanitize configfs_create() ...
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r--net/unix/af_unix.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 8ee85aa79fa..eb4277c3318 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -293,7 +293,7 @@ static struct sock *unix_find_socket_byinode(struct inode *i)
293 spin_lock(&unix_table_lock); 293 spin_lock(&unix_table_lock);
294 sk_for_each(s, node, 294 sk_for_each(s, node,
295 &unix_socket_table[i->i_ino & (UNIX_HASH_SIZE - 1)]) { 295 &unix_socket_table[i->i_ino & (UNIX_HASH_SIZE - 1)]) {
296 struct dentry *dentry = unix_sk(s)->dentry; 296 struct dentry *dentry = unix_sk(s)->path.dentry;
297 297
298 if (dentry && dentry->d_inode == i) { 298 if (dentry && dentry->d_inode == i) {
299 sock_hold(s); 299 sock_hold(s);
@@ -377,8 +377,7 @@ static void unix_sock_destructor(struct sock *sk)
377static int unix_release_sock(struct sock *sk, int embrion) 377static int unix_release_sock(struct sock *sk, int embrion)
378{ 378{
379 struct unix_sock *u = unix_sk(sk); 379 struct unix_sock *u = unix_sk(sk);
380 struct dentry *dentry; 380 struct path path;
381 struct vfsmount *mnt;
382 struct sock *skpair; 381 struct sock *skpair;
383 struct sk_buff *skb; 382 struct sk_buff *skb;
384 int state; 383 int state;
@@ -389,10 +388,9 @@ static int unix_release_sock(struct sock *sk, int embrion)
389 unix_state_lock(sk); 388 unix_state_lock(sk);
390 sock_orphan(sk); 389 sock_orphan(sk);
391 sk->sk_shutdown = SHUTDOWN_MASK; 390 sk->sk_shutdown = SHUTDOWN_MASK;
392 dentry = u->dentry; 391 path = u->path;
393 u->dentry = NULL; 392 u->path.dentry = NULL;
394 mnt = u->mnt; 393 u->path.mnt = NULL;
395 u->mnt = NULL;
396 state = sk->sk_state; 394 state = sk->sk_state;
397 sk->sk_state = TCP_CLOSE; 395 sk->sk_state = TCP_CLOSE;
398 unix_state_unlock(sk); 396 unix_state_unlock(sk);
@@ -425,10 +423,8 @@ static int unix_release_sock(struct sock *sk, int embrion)
425 kfree_skb(skb); 423 kfree_skb(skb);
426 } 424 }
427 425
428 if (dentry) { 426 if (path.dentry)
429 dput(dentry); 427 path_put(&path);
430 mntput(mnt);
431 }
432 428
433 sock_put(sk); 429 sock_put(sk);
434 430
@@ -641,8 +637,8 @@ static struct sock *unix_create1(struct net *net, struct socket *sock)
641 sk->sk_max_ack_backlog = net->unx.sysctl_max_dgram_qlen; 637 sk->sk_max_ack_backlog = net->unx.sysctl_max_dgram_qlen;
642 sk->sk_destruct = unix_sock_destructor; 638 sk->sk_destruct = unix_sock_destructor;
643 u = unix_sk(sk); 639 u = unix_sk(sk);
644 u->dentry = NULL; 640 u->path.dentry = NULL;
645 u->mnt = NULL; 641 u->path.mnt = NULL;
646 spin_lock_init(&u->lock); 642 spin_lock_init(&u->lock);
647 atomic_long_set(&u->inflight, 0); 643 atomic_long_set(&u->inflight, 0);
648 INIT_LIST_HEAD(&u->link); 644 INIT_LIST_HEAD(&u->link);
@@ -788,7 +784,7 @@ static struct sock *unix_find_other(struct net *net,
788 goto put_fail; 784 goto put_fail;
789 785
790 if (u->sk_type == type) 786 if (u->sk_type == type)
791 touch_atime(path.mnt, path.dentry); 787 touch_atime(&path);
792 788
793 path_put(&path); 789 path_put(&path);
794 790
@@ -802,9 +798,9 @@ static struct sock *unix_find_other(struct net *net,
802 u = unix_find_socket_byname(net, sunname, len, type, hash); 798 u = unix_find_socket_byname(net, sunname, len, type, hash);
803 if (u) { 799 if (u) {
804 struct dentry *dentry; 800 struct dentry *dentry;
805 dentry = unix_sk(u)->dentry; 801 dentry = unix_sk(u)->path.dentry;
806 if (dentry) 802 if (dentry)
807 touch_atime(unix_sk(u)->mnt, dentry); 803 touch_atime(&unix_sk(u)->path);
808 } else 804 } else
809 goto fail; 805 goto fail;
810 } 806 }
@@ -910,8 +906,7 @@ out_mknod_drop_write:
910 list = &unix_socket_table[addr->hash]; 906 list = &unix_socket_table[addr->hash];
911 } else { 907 } else {
912 list = &unix_socket_table[dentry->d_inode->i_ino & (UNIX_HASH_SIZE-1)]; 908 list = &unix_socket_table[dentry->d_inode->i_ino & (UNIX_HASH_SIZE-1)];
913 u->dentry = path.dentry; 909 u->path = path;
914 u->mnt = path.mnt;
915 } 910 }
916 911
917 err = 0; 912 err = 0;
@@ -1193,9 +1188,9 @@ restart:
1193 atomic_inc(&otheru->addr->refcnt); 1188 atomic_inc(&otheru->addr->refcnt);
1194 newu->addr = otheru->addr; 1189 newu->addr = otheru->addr;
1195 } 1190 }
1196 if (otheru->dentry) { 1191 if (otheru->path.dentry) {
1197 newu->dentry = dget(otheru->dentry); 1192 path_get(&otheru->path);
1198 newu->mnt = mntget(otheru->mnt); 1193 newu->path = otheru->path;
1199 } 1194 }
1200 1195
1201 /* Set credentials */ 1196 /* Set credentials */