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
Kirill Smelkov
linux
Commits
5da028a8
Commit
5da028a8
authored
Jun 27, 2017
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_compat_msghdr(): get rid of field-by-field copyin
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
ffb07550
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
17 deletions
+14
-17
net/compat.c
net/compat.c
+14
-17
No files found.
net/compat.c
View file @
5da028a8
...
@@ -37,21 +37,16 @@ int get_compat_msghdr(struct msghdr *kmsg,
...
@@ -37,21 +37,16 @@ int get_compat_msghdr(struct msghdr *kmsg,
struct
sockaddr
__user
**
save_addr
,
struct
sockaddr
__user
**
save_addr
,
struct
iovec
**
iov
)
struct
iovec
**
iov
)
{
{
compat_uptr_t
uaddr
,
uiov
,
tmp3
;
struct
compat_msghdr
msg
;
compat_size_t
nr_segs
;
ssize_t
err
;
ssize_t
err
;
if
(
!
access_ok
(
VERIFY_READ
,
umsg
,
sizeof
(
*
umsg
))
||
if
(
copy_from_user
(
&
msg
,
umsg
,
sizeof
(
*
umsg
)))
__get_user
(
uaddr
,
&
umsg
->
msg_name
)
||
__get_user
(
kmsg
->
msg_namelen
,
&
umsg
->
msg_namelen
)
||
__get_user
(
uiov
,
&
umsg
->
msg_iov
)
||
__get_user
(
nr_segs
,
&
umsg
->
msg_iovlen
)
||
__get_user
(
tmp3
,
&
umsg
->
msg_control
)
||
__get_user
(
kmsg
->
msg_controllen
,
&
umsg
->
msg_controllen
)
||
__get_user
(
kmsg
->
msg_flags
,
&
umsg
->
msg_flags
))
return
-
EFAULT
;
return
-
EFAULT
;
if
(
!
uaddr
)
kmsg
->
msg_flags
=
msg
.
msg_flags
;
kmsg
->
msg_namelen
=
msg
.
msg_namelen
;
if
(
!
msg
.
msg_name
)
kmsg
->
msg_namelen
=
0
;
kmsg
->
msg_namelen
=
0
;
if
(
kmsg
->
msg_namelen
<
0
)
if
(
kmsg
->
msg_namelen
<
0
)
...
@@ -59,14 +54,16 @@ int get_compat_msghdr(struct msghdr *kmsg,
...
@@ -59,14 +54,16 @@ int get_compat_msghdr(struct msghdr *kmsg,
if
(
kmsg
->
msg_namelen
>
sizeof
(
struct
sockaddr_storage
))
if
(
kmsg
->
msg_namelen
>
sizeof
(
struct
sockaddr_storage
))
kmsg
->
msg_namelen
=
sizeof
(
struct
sockaddr_storage
);
kmsg
->
msg_namelen
=
sizeof
(
struct
sockaddr_storage
);
kmsg
->
msg_control
=
compat_ptr
(
tmp3
);
kmsg
->
msg_control
=
compat_ptr
(
msg
.
msg_control
);
kmsg
->
msg_controllen
=
msg
.
msg_controllen
;
if
(
save_addr
)
if
(
save_addr
)
*
save_addr
=
compat_ptr
(
uaddr
);
*
save_addr
=
compat_ptr
(
msg
.
msg_name
);
if
(
uaddr
&&
kmsg
->
msg_namelen
)
{
if
(
msg
.
msg_name
&&
kmsg
->
msg_namelen
)
{
if
(
!
save_addr
)
{
if
(
!
save_addr
)
{
err
=
move_addr_to_kernel
(
compat_ptr
(
uaddr
),
err
=
move_addr_to_kernel
(
compat_ptr
(
msg
.
msg_name
),
kmsg
->
msg_namelen
,
kmsg
->
msg_namelen
,
kmsg
->
msg_name
);
kmsg
->
msg_name
);
if
(
err
<
0
)
if
(
err
<
0
)
...
@@ -77,13 +74,13 @@ int get_compat_msghdr(struct msghdr *kmsg,
...
@@ -77,13 +74,13 @@ int get_compat_msghdr(struct msghdr *kmsg,
kmsg
->
msg_namelen
=
0
;
kmsg
->
msg_namelen
=
0
;
}
}
if
(
nr_segs
>
UIO_MAXIOV
)
if
(
msg
.
msg_iovlen
>
UIO_MAXIOV
)
return
-
EMSGSIZE
;
return
-
EMSGSIZE
;
kmsg
->
msg_iocb
=
NULL
;
kmsg
->
msg_iocb
=
NULL
;
return
compat_import_iovec
(
save_addr
?
READ
:
WRITE
,
return
compat_import_iovec
(
save_addr
?
READ
:
WRITE
,
compat_ptr
(
uiov
),
nr_segs
,
compat_ptr
(
msg
.
msg_iov
),
msg
.
msg_iovlen
,
UIO_FASTIOV
,
iov
,
&
kmsg
->
msg_iter
);
UIO_FASTIOV
,
iov
,
&
kmsg
->
msg_iter
);
}
}
...
...
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