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
8c7b49b3
Commit
8c7b49b3
authored
Nov 30, 2009
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a struct file leak in do_mmap_pgoff()
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
f8b72560
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
18 deletions
+15
-18
mm/mmap.c
mm/mmap.c
+0
-18
mm/util.c
mm/util.c
+15
-0
No files found.
mm/mmap.c
View file @
8c7b49b3
...
...
@@ -948,24 +948,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
if
(
mm
->
map_count
>
sysctl_max_map_count
)
return
-
ENOMEM
;
if
(
flags
&
MAP_HUGETLB
)
{
struct
user_struct
*
user
=
NULL
;
if
(
file
)
return
-
EINVAL
;
/*
* VM_NORESERVE is used because the reservations will be
* taken when vm_ops->mmap() is called
* A dummy user value is used because we are not locking
* memory so no accounting is necessary
*/
len
=
ALIGN
(
len
,
huge_page_size
(
&
default_hstate
));
file
=
hugetlb_file_setup
(
HUGETLB_ANON_FILE
,
len
,
VM_NORESERVE
,
&
user
,
HUGETLB_ANONHUGE_INODE
);
if
(
IS_ERR
(
file
))
return
PTR_ERR
(
file
);
}
/* Obtain the address to map to. we verify (or select) it and ensure
* that it represents a valid section of the address space.
*/
...
...
mm/util.c
View file @
8c7b49b3
...
...
@@ -280,9 +280,24 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
unsigned
long
retval
=
-
EBADF
;
if
(
!
(
flags
&
MAP_ANONYMOUS
))
{
if
(
unlikely
(
flags
&
MAP_HUGETLB
))
return
-
EINVAL
;
file
=
fget
(
fd
);
if
(
!
file
)
goto
out
;
}
else
if
(
flags
&
MAP_HUGETLB
)
{
struct
user_struct
*
user
=
NULL
;
/*
* VM_NORESERVE is used because the reservations will be
* taken when vm_ops->mmap() is called
* A dummy user value is used because we are not locking
* memory so no accounting is necessary
*/
len
=
ALIGN
(
len
,
huge_page_size
(
&
default_hstate
));
file
=
hugetlb_file_setup
(
HUGETLB_ANON_FILE
,
len
,
VM_NORESERVE
,
&
user
,
HUGETLB_ANONHUGE_INODE
);
if
(
IS_ERR
(
file
))
return
PTR_ERR
(
file
);
}
flags
&=
~
(
MAP_EXECUTABLE
|
MAP_DENYWRITE
);
...
...
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