diff options
author | J. Bruce Fields <bfields@fieldses.org> | 2012-07-23 15:17:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-23 15:46:01 -0400 |
commit | 0ec4f431eb56d633da3a55da67d5c4b88886ccc7 (patch) | |
tree | 7a782163f6598510ae57b0523c2e625a8b26f2ce /fs/locks.c | |
parent | a66d2c8f7ec1284206ca7c14569e2a607583f1e3 (diff) |
locks: fix checking of fcntl_setlease argument
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. ]
Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/locks.c')
-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 fce6238d52c1..82c353304f9e 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -308,7 +308,7 @@ static int flock_make_lock(struct file *filp, struct file_lock **lock, | |||
308 | return 0; | 308 | return 0; |
309 | } | 309 | } |
310 | 310 | ||
311 | static int assign_type(struct file_lock *fl, int type) | 311 | static int assign_type(struct file_lock *fl, long type) |
312 | { | 312 | { |
313 | switch (type) { | 313 | switch (type) { |
314 | case F_RDLCK: | 314 | case F_RDLCK: |
@@ -445,7 +445,7 @@ static const struct lock_manager_operations lease_manager_ops = { | |||
445 | /* | 445 | /* |
446 | * Initialize a lease, use the default lock manager operations | 446 | * Initialize a lease, use the default lock manager operations |
447 | */ | 447 | */ |
448 | static int lease_init(struct file *filp, int type, struct file_lock *fl) | 448 | static int lease_init(struct file *filp, long type, struct file_lock *fl) |
449 | { | 449 | { |
450 | if (assign_type(fl, type) != 0) | 450 | if (assign_type(fl, type) != 0) |
451 | return -EINVAL; | 451 | return -EINVAL; |
@@ -463,7 +463,7 @@ static int lease_init(struct file *filp, int type, struct file_lock *fl) | |||
463 | } | 463 | } |
464 | 464 | ||
465 | /* Allocate a file_lock initialised to this type of lease */ | 465 | /* Allocate a file_lock initialised to this type of lease */ |
466 | static struct file_lock *lease_alloc(struct file *filp, int type) | 466 | static struct file_lock *lease_alloc(struct file *filp, long type) |
467 | { | 467 | { |
468 | struct file_lock *fl = locks_alloc_lock(); | 468 | struct file_lock *fl = locks_alloc_lock(); |
469 | int error = -ENOMEM; | 469 | int error = -ENOMEM; |