mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
use use SEEK_MAX to validate user lseek arguments
Add SEEK_MAX and use it to validate lseek arguments from userspace. Signed-off-by: Chris Snook <csnook@redhat.com> Acked-by: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
7b8e89249b
commit
1ae7075bcd
2 changed files with 3 additions and 2 deletions
|
@ -139,7 +139,7 @@ asmlinkage off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
if (origin <= 2) {
|
if (origin <= SEEK_MAX) {
|
||||||
loff_t res = vfs_llseek(file, offset, origin);
|
loff_t res = vfs_llseek(file, offset, origin);
|
||||||
retval = res;
|
retval = res;
|
||||||
if (res != (loff_t)retval)
|
if (res != (loff_t)retval)
|
||||||
|
@ -166,7 +166,7 @@ asmlinkage long sys_llseek(unsigned int fd, unsigned long offset_high,
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
if (origin > 2)
|
if (origin > SEEK_MAX)
|
||||||
goto out_putf;
|
goto out_putf;
|
||||||
|
|
||||||
offset = vfs_llseek(file, ((loff_t) offset_high << 32) | offset_low,
|
offset = vfs_llseek(file, ((loff_t) offset_high << 32) | offset_low,
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#define SEEK_SET 0 /* seek relative to beginning of file */
|
#define SEEK_SET 0 /* seek relative to beginning of file */
|
||||||
#define SEEK_CUR 1 /* seek relative to current file position */
|
#define SEEK_CUR 1 /* seek relative to current file position */
|
||||||
#define SEEK_END 2 /* seek relative to end of file */
|
#define SEEK_END 2 /* seek relative to end of file */
|
||||||
|
#define SEEK_MAX SEEK_END
|
||||||
|
|
||||||
/* And dynamically-tunable limits and defaults: */
|
/* And dynamically-tunable limits and defaults: */
|
||||||
struct files_stat_struct {
|
struct files_stat_struct {
|
||||||
|
|
Loading…
Reference in a new issue