locks: pass correct "before" pointer to locks_unlink_lock in generic_add_lease
Subsystems (2)
PATCH 1/1 locks: pass correct "before" pointer to locks_unlink_lock in generic_add_lease
The argument to locks_unlink_lock can't be just any pointer to a pointer. It must be a pointer to the fl_next field in the previous lock in the list.
--- fs/locks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/locks.c +1 -1
@@ -1619,7 +1619,7 @@ static int generic_add_lease(struct file *filp, long arg, struct file_lock **flpsmp_mb (); error =check_conflicting_open (dentry, arg);if (error) -locks_unlink_lock (flp); +locks_unlink_lock (before); out:if (is_deleg)mutex_unlock (&inode->i_mutex);
Signature · 1 line
1.9.3
Quoted 3 lines · Jeff Layton
The argument to
locks_unlink_lockcan't be just any pointer to a pointer. It must be a pointer to thefl_nextfield in the previous lock in the list.
Looks good,
This might explain some memory corruption I saw in the lease code while trying out a new creative (ab-)user of the lease code..
Quoted 5 lines · On Sat, 23 Aug 2014 04:48:18 -0700 Christoph Hellwig <[email protected]> wrote:
Quoted 3 lines · Jeff Layton
The argument to
locks_unlink_lockcan't be just any pointer to a pointer. It must be a pointer to thefl_nextfield in the previous lock in the list.
Quoted 7 lines
Looks good,
Reviewed-by Christoph Hellwig <[email protected]>This might explain some memory corruption I saw in the lease code while trying out a new creative (ab-)user of the lease code..
Hmmm maybe. I'd certainly test it out if you have a reproducer...
That locks_unlink_lock should only get called under some very strange (and rare) circumstances. It was added in commit 24cbe7845ea5 which describes the potential race there. I suppose it's possible but I had always considered that race to be more in the theoretical category than anything likely to happen under normal circumstances.
Signature · 1 line
Jeff Layton <[email protected]>