diff options
author | Peter Zijlstra <peterz@infradead.org> | 2016-10-08 04:12:28 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-10-18 06:21:28 -0400 |
commit | 5f43086bb9224987010460dcf3dee68fbd4f574d (patch) | |
tree | da735ff3aaa51076a11b84e1e05a89cbc5578253 | |
parent | 55a76b59b5fef408442e16121faa9eb00a65fd50 (diff) |
locking, fs/locks: Add missing file_sem locks
I overlooked a few code-paths that can lead to
locks_delete_global_locks().
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Jeff Layton <jlayton@poochiereds.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Bruce Fields <bfields@fieldses.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-fsdevel@vger.kernel.org
Cc: syzkaller <syzkaller@googlegroups.com>
Link: http://lkml.kernel.org/r/20161008081228.GF3142@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | fs/locks.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/locks.c b/fs/locks.c index ce93b416b490..22c5b4aa4961 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -1609,6 +1609,7 @@ int fcntl_getlease(struct file *filp) | |||
1609 | 1609 | ||
1610 | ctx = smp_load_acquire(&inode->i_flctx); | 1610 | ctx = smp_load_acquire(&inode->i_flctx); |
1611 | if (ctx && !list_empty_careful(&ctx->flc_lease)) { | 1611 | if (ctx && !list_empty_careful(&ctx->flc_lease)) { |
1612 | percpu_down_read_preempt_disable(&file_rwsem); | ||
1612 | spin_lock(&ctx->flc_lock); | 1613 | spin_lock(&ctx->flc_lock); |
1613 | time_out_leases(inode, &dispose); | 1614 | time_out_leases(inode, &dispose); |
1614 | list_for_each_entry(fl, &ctx->flc_lease, fl_list) { | 1615 | list_for_each_entry(fl, &ctx->flc_lease, fl_list) { |
@@ -1618,6 +1619,8 @@ int fcntl_getlease(struct file *filp) | |||
1618 | break; | 1619 | break; |
1619 | } | 1620 | } |
1620 | spin_unlock(&ctx->flc_lock); | 1621 | spin_unlock(&ctx->flc_lock); |
1622 | percpu_up_read_preempt_enable(&file_rwsem); | ||
1623 | |||
1621 | locks_dispose_list(&dispose); | 1624 | locks_dispose_list(&dispose); |
1622 | } | 1625 | } |
1623 | return type; | 1626 | return type; |
@@ -2529,11 +2532,14 @@ locks_remove_lease(struct file *filp, struct file_lock_context *ctx) | |||
2529 | if (list_empty(&ctx->flc_lease)) | 2532 | if (list_empty(&ctx->flc_lease)) |
2530 | return; | 2533 | return; |
2531 | 2534 | ||
2535 | percpu_down_read_preempt_disable(&file_rwsem); | ||
2532 | spin_lock(&ctx->flc_lock); | 2536 | spin_lock(&ctx->flc_lock); |
2533 | list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) | 2537 | list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) |
2534 | if (filp == fl->fl_file) | 2538 | if (filp == fl->fl_file) |
2535 | lease_modify(fl, F_UNLCK, &dispose); | 2539 | lease_modify(fl, F_UNLCK, &dispose); |
2536 | spin_unlock(&ctx->flc_lock); | 2540 | spin_unlock(&ctx->flc_lock); |
2541 | percpu_up_read_preempt_enable(&file_rwsem); | ||
2542 | |||
2537 | locks_dispose_list(&dispose); | 2543 | locks_dispose_list(&dispose); |
2538 | } | 2544 | } |
2539 | 2545 | ||