diff options
author | J. Bruce Fields <bfields@fieldses.org> | 2012-07-23 15:17:17 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-09 11:27:35 -0400 |
commit | dc525df9895f810ba777feec1540c7b822512c04 (patch) | |
tree | 5e66ea3b83f6778aa27276aec791b289322f8526 /fs | |
parent | f58f16f2039cca9dc58a406593e5f46c6a35e0df (diff) |
locks: fix checking of fcntl_setlease argument
commit 0ec4f431eb56d633da3a55da67d5c4b88886ccc7 upstream.
The only checks of the long argument passed to fcntl(fd,F_SETLEASE,.)
are done after converting the long to an int. Thus some illegal values
may be let through and cause problems in later code.
[ They actually *don't* cause problems in mainline, as of Dave Jones's
commit 8d657eb3b438 "Remove easily user-triggerable BUG from
generic_setlease", but we should fix this anyway. And this patch will
be necessary to fix real bugs on earlier kernels. ]
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/locks.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/locks.c b/fs/locks.c index b286539d547..35388d524c7 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -315,7 +315,7 @@ static int flock_make_lock(struct file *filp, struct file_lock **lock, | |||
315 | return 0; | 315 | return 0; |
316 | } | 316 | } |
317 | 317 | ||
318 | static int assign_type(struct file_lock *fl, int type) | 318 | static int assign_type(struct file_lock *fl, long type) |
319 | { | 319 | { |
320 | switch (type) { | 320 | switch (type) { |
321 | case F_RDLCK: | 321 | case F_RDLCK: |
@@ -452,7 +452,7 @@ static const struct lock_manager_operations lease_manager_ops = { | |||
452 | /* | 452 | /* |
453 | * Initialize a lease, use the default lock manager operations | 453 | * Initialize a lease, use the default lock manager operations |
454 | */ | 454 | */ |
455 | static int lease_init(struct file *filp, int type, struct file_lock *fl) | 455 | static int lease_init(struct file *filp, long type, struct file_lock *fl) |
456 | { | 456 | { |
457 | if (assign_type(fl, type) != 0) | 457 | if (assign_type(fl, type) != 0) |
458 | return -EINVAL; | 458 | return -EINVAL; |
@@ -470,7 +470,7 @@ static int lease_init(struct file *filp, int type, struct file_lock *fl) | |||
470 | } | 470 | } |
471 | 471 | ||
472 | /* Allocate a file_lock initialised to this type of lease */ | 472 | /* Allocate a file_lock initialised to this type of lease */ |
473 | static struct file_lock *lease_alloc(struct file *filp, int type) | 473 | static struct file_lock *lease_alloc(struct file *filp, long type) |
474 | { | 474 | { |
475 | struct file_lock *fl = locks_alloc_lock(); | 475 | struct file_lock *fl = locks_alloc_lock(); |
476 | int error = -ENOMEM; | 476 | int error = -ENOMEM; |