Skip to contentSkip to conversation

locks: pass correct "before" pointer to locks_unlink_lock in generic_add_lease

PATCH In review Jeff Layton 3 participants 3 messages Aug 23, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index cb66fb05ad4a..bb08857f90b5 100644
@@ -1619,7 +1619,7 @@ static int generic_add_lease(struct file *filp, long arg, struct file_lock **flp
 	smp_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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Jeff Layton

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.

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..

#2 lore raw
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_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.

Quoted 7 lines

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..

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]>