diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-02 23:25:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-02 23:25:04 -0400 |
commit | aab174f0df5d72d31caccf281af5f614fa254578 (patch) | |
tree | 2a172c5009c4ac8755e858593154c258ce7709a0 /net/sctp/socket.c | |
parent | ca41cc96b2813221b05af57d0355157924de5a07 (diff) | |
parent | 2bd2c1941f141ad780135ccc1cd08ca71a24f10a (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs update from Al Viro:
- big one - consolidation of descriptor-related logics; almost all of
that is moved to fs/file.c
(BTW, I'm seriously tempted to rename the result to fd.c. As it is,
we have a situation when file_table.c is about handling of struct
file and file.c is about handling of descriptor tables; the reasons
are historical - file_table.c used to be about a static array of
struct file we used to have way back).
A lot of stray ends got cleaned up and converted to saner primitives,
disgusting mess in android/binder.c is still disgusting, but at least
doesn't poke so much in descriptor table guts anymore. A bunch of
relatively minor races got fixed in process, plus an ext4 struct file
leak.
- related thing - fget_light() partially unuglified; see fdget() in
there (and yes, it generates the code as good as we used to have).
- also related - bits of Cyrill's procfs stuff that got entangled into
that work; _not_ all of it, just the initial move to fs/proc/fd.c and
switch of fdinfo to seq_file.
- Alex's fs/coredump.c spiltoff - the same story, had been easier to
take that commit than mess with conflicts. The rest is a separate
pile, this was just a mechanical code movement.
- a few misc patches all over the place. Not all for this cycle,
there'll be more (and quite a few currently sit in akpm's tree)."
Fix up trivial conflicts in the android binder driver, and some fairly
simple conflicts due to two different changes to the sock_alloc_file()
interface ("take descriptor handling from sock_alloc_file() to callers"
vs "net: Providing protocol type via system.sockprotoname xattr of
/proc/PID/fd entries" adding a dentry name to the socket)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (72 commits)
MAX_LFS_FILESIZE should be a loff_t
compat: fs: Generic compat_sys_sendfile implementation
fs: push rcu_barrier() from deactivate_locked_super() to filesystems
btrfs: reada_extent doesn't need kref for refcount
coredump: move core dump functionality into its own file
coredump: prevent double-free on an error path in core dumper
usb/gadget: fix misannotations
fcntl: fix misannotations
ceph: don't abuse d_delete() on failure exits
hypfs: ->d_parent is never NULL or negative
vfs: delete surplus inode NULL check
switch simple cases of fget_light to fdget
new helpers: fdget()/fdput()
switch o2hb_region_dev_write() to fget_light()
proc_map_files_readdir(): don't bother with grabbing files
make get_file() return its argument
vhost_set_vring(): turn pollstart/pollstop into bool
switch prctl_set_mm_exe_file() to fget_light()
switch xfs_find_handle() to fget_light()
switch xfs_swapext() to fget_light()
...
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r-- | net/sctp/socket.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index d37d24ff197f..59d16ea927f0 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -70,6 +70,7 @@ | |||
70 | #include <linux/init.h> | 70 | #include <linux/init.h> |
71 | #include <linux/crypto.h> | 71 | #include <linux/crypto.h> |
72 | #include <linux/slab.h> | 72 | #include <linux/slab.h> |
73 | #include <linux/file.h> | ||
73 | 74 | ||
74 | #include <net/ip.h> | 75 | #include <net/ip.h> |
75 | #include <net/icmp.h> | 76 | #include <net/icmp.h> |
@@ -4292,6 +4293,7 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval | |||
4292 | { | 4293 | { |
4293 | sctp_peeloff_arg_t peeloff; | 4294 | sctp_peeloff_arg_t peeloff; |
4294 | struct socket *newsock; | 4295 | struct socket *newsock; |
4296 | struct file *newfile; | ||
4295 | int retval = 0; | 4297 | int retval = 0; |
4296 | 4298 | ||
4297 | if (len < sizeof(sctp_peeloff_arg_t)) | 4299 | if (len < sizeof(sctp_peeloff_arg_t)) |
@@ -4305,22 +4307,35 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval | |||
4305 | goto out; | 4307 | goto out; |
4306 | 4308 | ||
4307 | /* Map the socket to an unused fd that can be returned to the user. */ | 4309 | /* Map the socket to an unused fd that can be returned to the user. */ |
4308 | retval = sock_map_fd(newsock, 0); | 4310 | retval = get_unused_fd(); |
4309 | if (retval < 0) { | 4311 | if (retval < 0) { |
4310 | sock_release(newsock); | 4312 | sock_release(newsock); |
4311 | goto out; | 4313 | goto out; |
4312 | } | 4314 | } |
4313 | 4315 | ||
4316 | newfile = sock_alloc_file(newsock, 0, NULL); | ||
4317 | if (unlikely(IS_ERR(newfile))) { | ||
4318 | put_unused_fd(retval); | ||
4319 | sock_release(newsock); | ||
4320 | return PTR_ERR(newfile); | ||
4321 | } | ||
4322 | |||
4314 | SCTP_DEBUG_PRINTK("%s: sk: %p newsk: %p sd: %d\n", | 4323 | SCTP_DEBUG_PRINTK("%s: sk: %p newsk: %p sd: %d\n", |
4315 | __func__, sk, newsock->sk, retval); | 4324 | __func__, sk, newsock->sk, retval); |
4316 | 4325 | ||
4317 | /* Return the fd mapped to the new socket. */ | 4326 | /* Return the fd mapped to the new socket. */ |
4327 | if (put_user(len, optlen)) { | ||
4328 | fput(newfile); | ||
4329 | put_unused_fd(retval); | ||
4330 | return -EFAULT; | ||
4331 | } | ||
4318 | peeloff.sd = retval; | 4332 | peeloff.sd = retval; |
4319 | if (put_user(len, optlen)) | 4333 | if (copy_to_user(optval, &peeloff, len)) { |
4334 | fput(newfile); | ||
4335 | put_unused_fd(retval); | ||
4320 | return -EFAULT; | 4336 | return -EFAULT; |
4321 | if (copy_to_user(optval, &peeloff, len)) | 4337 | } |
4322 | retval = -EFAULT; | 4338 | fd_install(retval, newfile); |
4323 | |||
4324 | out: | 4339 | out: |
4325 | return retval; | 4340 | return retval; |
4326 | } | 4341 | } |