Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
da184284
Commit
da184284
authored
Mar 21, 2015
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: switch importing msghdr from userland to {compat_,}import_iovec()
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
602bd0e9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
31 deletions
+20
-31
include/net/compat.h
include/net/compat.h
+1
-1
net/compat.c
net/compat.c
+7
-11
net/socket.c
net/socket.c
+12
-19
No files found.
include/net/compat.h
View file @
da184284
...
@@ -40,7 +40,7 @@ int compat_sock_get_timestampns(struct sock *, struct timespec __user *);
...
@@ -40,7 +40,7 @@ int compat_sock_get_timestampns(struct sock *, struct timespec __user *);
#define compat_mmsghdr mmsghdr
#define compat_mmsghdr mmsghdr
#endif
/* defined(CONFIG_COMPAT) */
#endif
/* defined(CONFIG_COMPAT) */
ssize_
t
get_compat_msghdr
(
struct
msghdr
*
,
struct
compat_msghdr
__user
*
,
in
t
get_compat_msghdr
(
struct
msghdr
*
,
struct
compat_msghdr
__user
*
,
struct
sockaddr
__user
**
,
struct
iovec
**
);
struct
sockaddr
__user
**
,
struct
iovec
**
);
asmlinkage
long
compat_sys_sendmsg
(
int
,
struct
compat_msghdr
__user
*
,
asmlinkage
long
compat_sys_sendmsg
(
int
,
struct
compat_msghdr
__user
*
,
unsigned
int
);
unsigned
int
);
...
...
net/compat.c
View file @
da184284
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include <net/compat.h>
#include <net/compat.h>
ssize_
t
get_compat_msghdr
(
struct
msghdr
*
kmsg
,
in
t
get_compat_msghdr
(
struct
msghdr
*
kmsg
,
struct
compat_msghdr
__user
*
umsg
,
struct
compat_msghdr
__user
*
umsg
,
struct
sockaddr
__user
**
save_addr
,
struct
sockaddr
__user
**
save_addr
,
struct
iovec
**
iov
)
struct
iovec
**
iov
)
...
@@ -81,13 +81,9 @@ ssize_t get_compat_msghdr(struct msghdr *kmsg,
...
@@ -81,13 +81,9 @@ ssize_t get_compat_msghdr(struct msghdr *kmsg,
kmsg
->
msg_iocb
=
NULL
;
kmsg
->
msg_iocb
=
NULL
;
err
=
compat_rw_copy_check_uvector
(
save_addr
?
READ
:
WRITE
,
return
compat_import_iovec
(
save_addr
?
READ
:
WRITE
,
compat_ptr
(
uiov
),
nr_segs
,
compat_ptr
(
uiov
),
nr_segs
,
UIO_FASTIOV
,
*
iov
,
iov
);
UIO_FASTIOV
,
iov
,
&
kmsg
->
msg_iter
);
if
(
err
>=
0
)
iov_iter_init
(
&
kmsg
->
msg_iter
,
save_addr
?
READ
:
WRITE
,
*
iov
,
nr_segs
,
err
);
return
err
;
}
}
/* Bleech... */
/* Bleech... */
...
...
net/socket.c
View file @
da184284
...
@@ -1841,7 +1841,7 @@ struct used_address {
...
@@ -1841,7 +1841,7 @@ struct used_address {
unsigned
int
name_len
;
unsigned
int
name_len
;
};
};
static
ssize_
t
copy_msghdr_from_user
(
struct
msghdr
*
kmsg
,
static
in
t
copy_msghdr_from_user
(
struct
msghdr
*
kmsg
,
struct
user_msghdr
__user
*
umsg
,
struct
user_msghdr
__user
*
umsg
,
struct
sockaddr
__user
**
save_addr
,
struct
sockaddr
__user
**
save_addr
,
struct
iovec
**
iov
)
struct
iovec
**
iov
)
...
@@ -1890,13 +1890,8 @@ static ssize_t copy_msghdr_from_user(struct msghdr *kmsg,
...
@@ -1890,13 +1890,8 @@ static ssize_t copy_msghdr_from_user(struct msghdr *kmsg,
kmsg
->
msg_iocb
=
NULL
;
kmsg
->
msg_iocb
=
NULL
;
err
=
rw_copy_check_uvector
(
save_addr
?
READ
:
WRITE
,
return
import_iovec
(
save_addr
?
READ
:
WRITE
,
uiov
,
nr_segs
,
uiov
,
nr_segs
,
UIO_FASTIOV
,
iov
,
&
kmsg
->
msg_iter
);
UIO_FASTIOV
,
*
iov
,
iov
);
if
(
err
>=
0
)
iov_iter_init
(
&
kmsg
->
msg_iter
,
save_addr
?
READ
:
WRITE
,
*
iov
,
nr_segs
,
err
);
return
err
;
}
}
static
int
___sys_sendmsg
(
struct
socket
*
sock
,
struct
user_msghdr
__user
*
msg
,
static
int
___sys_sendmsg
(
struct
socket
*
sock
,
struct
user_msghdr
__user
*
msg
,
...
@@ -1921,8 +1916,8 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
...
@@ -1921,8 +1916,8 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
else
else
err
=
copy_msghdr_from_user
(
msg_sys
,
msg
,
NULL
,
&
iov
);
err
=
copy_msghdr_from_user
(
msg_sys
,
msg
,
NULL
,
&
iov
);
if
(
err
<
0
)
if
(
err
<
0
)
goto
out_freeiov
;
return
err
;
total_len
=
err
;
total_len
=
iov_iter_count
(
&
msg_sys
->
msg_iter
)
;
err
=
-
ENOBUFS
;
err
=
-
ENOBUFS
;
...
@@ -1988,7 +1983,6 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
...
@@ -1988,7 +1983,6 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
if
(
ctl_buf
!=
ctl
)
if
(
ctl_buf
!=
ctl
)
sock_kfree_s
(
sock
->
sk
,
ctl_buf
,
ctl_len
);
sock_kfree_s
(
sock
->
sk
,
ctl_buf
,
ctl_len
);
out_freeiov:
out_freeiov:
if
(
iov
!=
iovstack
)
kfree
(
iov
);
kfree
(
iov
);
return
err
;
return
err
;
}
}
...
@@ -2114,8 +2108,8 @@ static int ___sys_recvmsg(struct socket *sock, struct user_msghdr __user *msg,
...
@@ -2114,8 +2108,8 @@ static int ___sys_recvmsg(struct socket *sock, struct user_msghdr __user *msg,
else
else
err
=
copy_msghdr_from_user
(
msg_sys
,
msg
,
&
uaddr
,
&
iov
);
err
=
copy_msghdr_from_user
(
msg_sys
,
msg
,
&
uaddr
,
&
iov
);
if
(
err
<
0
)
if
(
err
<
0
)
goto
out_freeiov
;
return
err
;
total_len
=
err
;
total_len
=
iov_iter_count
(
&
msg_sys
->
msg_iter
)
;
cmsg_ptr
=
(
unsigned
long
)
msg_sys
->
msg_control
;
cmsg_ptr
=
(
unsigned
long
)
msg_sys
->
msg_control
;
msg_sys
->
msg_flags
=
flags
&
(
MSG_CMSG_CLOEXEC
|
MSG_CMSG_COMPAT
);
msg_sys
->
msg_flags
=
flags
&
(
MSG_CMSG_CLOEXEC
|
MSG_CMSG_COMPAT
);
...
@@ -2153,7 +2147,6 @@ static int ___sys_recvmsg(struct socket *sock, struct user_msghdr __user *msg,
...
@@ -2153,7 +2147,6 @@ static int ___sys_recvmsg(struct socket *sock, struct user_msghdr __user *msg,
err
=
len
;
err
=
len
;
out_freeiov:
out_freeiov:
if
(
iov
!=
iovstack
)
kfree
(
iov
);
kfree
(
iov
);
return
err
;
return
err
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment