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
12cd5433
Commit
12cd5433
authored
Mar 04, 2002
by
Benjamin LaHaise
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LFS style EOVERFLOW checks to sendfile*
parent
87aad03b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
mm/filemap.c
mm/filemap.c
+22
-7
No files found.
mm/filemap.c
View file @
12cd5433
...
@@ -1715,7 +1715,7 @@ static int file_send_actor(read_descriptor_t * desc, struct page *page, unsigned
...
@@ -1715,7 +1715,7 @@ static int file_send_actor(read_descriptor_t * desc, struct page *page, unsigned
return
written
;
return
written
;
}
}
static
ssize_t
common_sendfile
(
int
out_fd
,
int
in_fd
,
loff_t
*
offset
,
size_t
count
)
static
ssize_t
common_sendfile
(
int
out_fd
,
int
in_fd
,
loff_t
*
offset
,
size_t
count
,
loff_t
max
)
{
{
ssize_t
retval
;
ssize_t
retval
;
struct
file
*
in_file
,
*
out_file
;
struct
file
*
in_file
,
*
out_file
;
...
@@ -1760,10 +1760,22 @@ static ssize_t common_sendfile(int out_fd, int in_fd, loff_t *offset, size_t cou
...
@@ -1760,10 +1760,22 @@ static ssize_t common_sendfile(int out_fd, int in_fd, loff_t *offset, size_t cou
retval
=
0
;
retval
=
0
;
if
(
count
)
{
if
(
count
)
{
read_descriptor_t
desc
;
read_descriptor_t
desc
;
loff_t
pos
;
if
(
!
offset
)
if
(
!
offset
)
offset
=
&
in_file
->
f_pos
;
offset
=
&
in_file
->
f_pos
;
pos
=
*
offset
;
retval
=
-
EINVAL
;
if
(
unlikely
(
pos
<
0
))
goto
fput_out
;
if
(
unlikely
(
pos
+
count
>
max
))
{
retval
=
-
EOVERFLOW
;
if
(
pos
>=
max
)
goto
fput_out
;
count
=
max
-
pos
;
}
desc
.
written
=
0
;
desc
.
written
=
0
;
desc
.
count
=
count
;
desc
.
count
=
count
;
desc
.
buf
=
(
char
*
)
out_file
;
desc
.
buf
=
(
char
*
)
out_file
;
...
@@ -1773,6 +1785,9 @@ static ssize_t common_sendfile(int out_fd, int in_fd, loff_t *offset, size_t cou
...
@@ -1773,6 +1785,9 @@ static ssize_t common_sendfile(int out_fd, int in_fd, loff_t *offset, size_t cou
retval
=
desc
.
written
;
retval
=
desc
.
written
;
if
(
!
retval
)
if
(
!
retval
)
retval
=
desc
.
error
;
retval
=
desc
.
error
;
pos
=
*
offset
;
if
(
pos
>
max
)
retval
=
-
EOVERFLOW
;
}
}
fput_out:
fput_out:
...
@@ -1794,9 +1809,9 @@ asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t cou
...
@@ -1794,9 +1809,9 @@ asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t cou
pos
=
off
;
pos
=
off
;
ppos
=
&
pos
;
ppos
=
&
pos
;
}
}
ret
=
common_sendfile
(
out_fd
,
in_fd
,
ppos
,
count
);
ret
=
common_sendfile
(
out_fd
,
in_fd
,
ppos
,
count
,
MAX_NON_LFS
);
if
(
offset
)
if
(
offset
&&
put_user
(
pos
,
offset
)
)
put_user
((
off_t
)
pos
,
offset
)
;
ret
=
-
EFAULT
;
return
ret
;
return
ret
;
}
}
...
@@ -1809,9 +1824,9 @@ asmlinkage ssize_t sys_sendfile64(int out_fd, int in_fd, loff_t *offset, size_t
...
@@ -1809,9 +1824,9 @@ asmlinkage ssize_t sys_sendfile64(int out_fd, int in_fd, loff_t *offset, size_t
return
-
EFAULT
;
return
-
EFAULT
;
ppos
=
&
pos
;
ppos
=
&
pos
;
}
}
ret
=
common_sendfile
(
out_fd
,
in_fd
,
ppos
,
count
);
ret
=
common_sendfile
(
out_fd
,
in_fd
,
ppos
,
count
,
MAX_LFS_FILESIZE
);
if
(
offset
)
if
(
offset
&&
put_user
(
pos
,
offset
)
)
put_user
(
pos
,
offset
)
;
ret
=
-
EFAULT
;
return
ret
;
return
ret
;
}
}
...
...
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