mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
unexport sock_map_fd(), switch to sock_alloc_file()
Both modular callers of sock_map_fd() had been buggy; sctp one leaks descriptor and file if copy_to_user() fails, 9p one shouldn't be exposing file in the descriptor table at all. Switch both to sock_alloc_file(), export it, unexport sock_map_fd() and make it static. Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
2840763051
commit
56b31d1c9f
4 changed files with 32 additions and 18 deletions
|
|
@ -793,30 +793,28 @@ static int p9_fd_open(struct p9_client *client, int rfd, int wfd)
|
|||
static int p9_socket_open(struct p9_client *client, struct socket *csocket)
|
||||
{
|
||||
struct p9_trans_fd *p;
|
||||
int ret, fd;
|
||||
struct file *file;
|
||||
int ret;
|
||||
|
||||
p = kmalloc(sizeof(struct p9_trans_fd), GFP_KERNEL);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
|
||||
csocket->sk->sk_allocation = GFP_NOIO;
|
||||
fd = sock_map_fd(csocket, 0);
|
||||
if (fd < 0) {
|
||||
file = sock_alloc_file(csocket, 0);
|
||||
if (IS_ERR(file)) {
|
||||
pr_err("%s (%d): failed to map fd\n",
|
||||
__func__, task_pid_nr(current));
|
||||
sock_release(csocket);
|
||||
kfree(p);
|
||||
return fd;
|
||||
return PTR_ERR(file);
|
||||
}
|
||||
|
||||
get_file(csocket->file);
|
||||
get_file(csocket->file);
|
||||
p->wr = p->rd = csocket->file;
|
||||
get_file(file);
|
||||
p->wr = p->rd = file;
|
||||
client->trans = p;
|
||||
client->status = Connected;
|
||||
|
||||
sys_close(fd); /* still racy */
|
||||
|
||||
p->rd->f_flags |= O_NONBLOCK;
|
||||
|
||||
p->conn = p9_conn_create(client);
|
||||
|
|
|
|||
Loading…
Reference in a new issue