Skip to content

Commit

Permalink
locks: fix checking of fcntl_setlease argument
Browse files Browse the repository at this point in the history
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 8d657eb "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: [email protected]
Signed-off-by: J. Bruce Fields <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
bfields authored and torvalds committed Jul 23, 2012
1 parent a66d2c8 commit 0ec4f43
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static int flock_make_lock(struct file *filp, struct file_lock **lock,
return 0;
}

static int assign_type(struct file_lock *fl, int type)
static int assign_type(struct file_lock *fl, long type)
{
switch (type) {
case F_RDLCK:
Expand Down Expand Up @@ -445,7 +445,7 @@ static const struct lock_manager_operations lease_manager_ops = {
/*
* Initialize a lease, use the default lock manager operations
*/
static int lease_init(struct file *filp, int type, struct file_lock *fl)
static int lease_init(struct file *filp, long type, struct file_lock *fl)
{
if (assign_type(fl, type) != 0)
return -EINVAL;
Expand All @@ -463,7 +463,7 @@ static int lease_init(struct file *filp, int type, struct file_lock *fl)
}

/* Allocate a file_lock initialised to this type of lease */
static struct file_lock *lease_alloc(struct file *filp, int type)
static struct file_lock *lease_alloc(struct file *filp, long type)
{
struct file_lock *fl = locks_alloc_lock();
int error = -ENOMEM;
Expand Down

0 comments on commit 0ec4f43

Please sign in to comment.