Commit 326be7b484843988afe57566b627fb7a70beac56

Authored by Al Viro
1 parent 65cfc67223

Allow passing O_PATH descriptors via SCM_RIGHTS datagrams

Just need to make sure that AF_UNIX garbage collector won't
confuse O_PATHed socket on filesystem for real AF_UNIX opened
socket.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 3 changed files with 4 additions and 2 deletions Side-by-side Diff

... ... @@ -305,6 +305,8 @@
305 305 return file;
306 306 }
307 307  
  308 +EXPORT_SYMBOL(fget_raw);
  309 +
308 310 /*
309 311 * Lightweight file lookup - no refcnt increment if fd table isn't shared.
310 312 *
... ... @@ -95,7 +95,7 @@
95 95 int fd = fdp[i];
96 96 struct file *file;
97 97  
98   - if (fd < 0 || !(file = fget(fd)))
  98 + if (fd < 0 || !(file = fget_raw(fd)))
99 99 return -EBADF;
100 100 *fpp++ = file;
101 101 fpl->count++;
... ... @@ -104,7 +104,7 @@
104 104 /*
105 105 * Socket ?
106 106 */
107   - if (S_ISSOCK(inode->i_mode)) {
  107 + if (S_ISSOCK(inode->i_mode) && !(filp->f_mode & FMODE_PATH)) {
108 108 struct socket *sock = SOCKET_I(inode);
109 109 struct sock *s = sock->sk;
110 110