Skip to content

Commit

Permalink
locks: prevent side-effects of locks_release_private before file_lock…
Browse files Browse the repository at this point in the history
… is initialized

When calling fcntl(fd, F_SETLEASE, lck) [with lck=F_WRLCK or F_RDLCK],
the custom signal or owner (if any were previously set using F_SETSIG
or F_SETOWN fcntls) would be reset when F_SETLEASE was called for the
second time on the same file descriptor.

This bug is a regression of 2.6.37 and is described here:
https://bugzilla.kernel.org/show_bug.cgi?id=43336

This patch reverts a commit from Oct 2004 (with subject "nfs4 lease:
move the f_delown processing") which originally introduced the
lm_release_private callback.

Signed-off-by: Filipe Brandenburger <filbranden@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
Filipe Brandenburger authored and J. Bruce Fields committed Jul 27, 2012
1 parent 57c8b13 commit 3b6e272
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,18 +427,8 @@ static void lease_break_callback(struct file_lock *fl)
kill_fasync(&fl->fl_fasync, SIGIO, POLL_MSG);
}

static void lease_release_private_callback(struct file_lock *fl)
{
if (!fl->fl_file)
return;

f_delown(fl->fl_file);
fl->fl_file->f_owner.signum = 0;
}

static const struct lock_manager_operations lease_manager_ops = {
.lm_break = lease_break_callback,
.lm_release_private = lease_release_private_callback,
.lm_change = lease_modify,
};

Expand Down Expand Up @@ -1155,8 +1145,13 @@ int lease_modify(struct file_lock **before, int arg)
return error;
lease_clear_pending(fl, arg);
locks_wake_up_blocks(fl);
if (arg == F_UNLCK)
if (arg == F_UNLCK) {
struct file *filp = fl->fl_file;

f_delown(filp);
filp->f_owner.signum = 0;
locks_delete_lock(before);
}
return 0;
}

Expand Down

0 comments on commit 3b6e272

Please sign in to comment.