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
e4448ed8
Commit
e4448ed8
authored
May 13, 2017
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpf: don't open-code memdup_user()
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
a9bd8dfa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
29 deletions
+16
-29
kernel/bpf/syscall.c
kernel/bpf/syscall.c
+16
-29
No files found.
kernel/bpf/syscall.c
View file @
e4448ed8
...
...
@@ -322,14 +322,11 @@ static int map_lookup_elem(union bpf_attr *attr)
if
(
IS_ERR
(
map
))
return
PTR_ERR
(
map
);
err
=
-
ENOMEM
;
key
=
kmalloc
(
map
->
key_size
,
GFP_USER
);
if
(
!
key
)
key
=
memdup_user
(
ukey
,
map
->
key_size
)
;
if
(
IS_ERR
(
key
))
{
err
=
PTR_ERR
(
key
);
goto
err_put
;
err
=
-
EFAULT
;
if
(
copy_from_user
(
key
,
ukey
,
map
->
key_size
)
!=
0
)
goto
free_key
;
}
if
(
map
->
map_type
==
BPF_MAP_TYPE_PERCPU_HASH
||
map
->
map_type
==
BPF_MAP_TYPE_LRU_PERCPU_HASH
||
...
...
@@ -402,14 +399,11 @@ static int map_update_elem(union bpf_attr *attr)
if
(
IS_ERR
(
map
))
return
PTR_ERR
(
map
);
err
=
-
ENOMEM
;
key
=
kmalloc
(
map
->
key_size
,
GFP_USER
);
if
(
!
key
)
key
=
memdup_user
(
ukey
,
map
->
key_size
)
;
if
(
IS_ERR
(
key
))
{
err
=
PTR_ERR
(
key
);
goto
err_put
;
err
=
-
EFAULT
;
if
(
copy_from_user
(
key
,
ukey
,
map
->
key_size
)
!=
0
)
goto
free_key
;
}
if
(
map
->
map_type
==
BPF_MAP_TYPE_PERCPU_HASH
||
map
->
map_type
==
BPF_MAP_TYPE_LRU_PERCPU_HASH
||
...
...
@@ -488,14 +482,11 @@ static int map_delete_elem(union bpf_attr *attr)
if
(
IS_ERR
(
map
))
return
PTR_ERR
(
map
);
err
=
-
ENOMEM
;
key
=
kmalloc
(
map
->
key_size
,
GFP_USER
);
if
(
!
key
)
key
=
memdup_user
(
ukey
,
map
->
key_size
)
;
if
(
IS_ERR
(
key
))
{
err
=
PTR_ERR
(
key
);
goto
err_put
;
err
=
-
EFAULT
;
if
(
copy_from_user
(
key
,
ukey
,
map
->
key_size
)
!=
0
)
goto
free_key
;
}
preempt_disable
();
__this_cpu_inc
(
bpf_prog_active
);
...
...
@@ -507,7 +498,6 @@ static int map_delete_elem(union bpf_attr *attr)
if
(
!
err
)
trace_bpf_map_delete_elem
(
map
,
ufd
,
key
);
free_key:
kfree
(
key
);
err_put:
fdput
(
f
);
...
...
@@ -536,14 +526,11 @@ static int map_get_next_key(union bpf_attr *attr)
return
PTR_ERR
(
map
);
if
(
ukey
)
{
err
=
-
ENOMEM
;
key
=
kmalloc
(
map
->
key_size
,
GFP_USER
);
if
(
!
key
)
key
=
memdup_user
(
ukey
,
map
->
key_size
)
;
if
(
IS_ERR
(
key
))
{
err
=
PTR_ERR
(
key
);
goto
err_put
;
err
=
-
EFAULT
;
if
(
copy_from_user
(
key
,
ukey
,
map
->
key_size
)
!=
0
)
goto
free_key
;
}
}
else
{
key
=
NULL
;
}
...
...
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