public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] locks: fix fasync_struct memory leak in lease upgrade/downgrade handling
@ 2015-03-05  0:06 Jeff Layton
  2015-03-05  6:57 ` Daniel Wagner
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Layton @ 2015-03-05  0:06 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, bfields, daniel.wagner, viro

Commit 8634b51f6ca2 (locks: convert lease handling to file_lock_context)
introduced a regression in the handling of lease upgrade/downgrades.

In the event that we already have a lease on a file and are going to
either upgrade or downgrade it, we skip doing any list insertion or
deletion and skip to re-calling lm_setup on the existing lease.

As of commit 8634b51f6ca2 however, we end up calling lm_setup on the
lease that was passed in, instead of on the existing lease. This causes
us to leak the fasync_struct that was allocated in the event that there
was not already an existing one (as it always appeared that there
wasn't one).

Fixes: 8634b51f6ca2 (locks: convert lease handling to file_lock_context)
Reported-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
---
 fs/locks.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/locks.c b/fs/locks.c
index 365c82e1b3a9..f1bad681fc1c 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1665,7 +1665,8 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
 	}
 
 	if (my_fl != NULL) {
-		error = lease->fl_lmops->lm_change(my_fl, arg, &dispose);
+		lease = my_fl;
+		error = lease->fl_lmops->lm_change(lease, arg, &dispose);
 		if (error)
 			goto out;
 		goto out_setup;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] locks: fix fasync_struct memory leak in lease upgrade/downgrade handling
  2015-03-05  0:06 [PATCH] locks: fix fasync_struct memory leak in lease upgrade/downgrade handling Jeff Layton
@ 2015-03-05  6:57 ` Daniel Wagner
  2015-03-05 11:50   ` Jeff Layton
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Wagner @ 2015-03-05  6:57 UTC (permalink / raw)
  To: Jeff Layton, linux-fsdevel; +Cc: linux-kernel, bfields, viro

Hi Jeff,

On 03/05/2015 01:06 AM, Jeff Layton wrote:
> Commit 8634b51f6ca2 (locks: convert lease handling to file_lock_context)
> introduced a regression in the handling of lease upgrade/downgrades.
> 
> In the event that we already have a lease on a file and are going to
> either upgrade or downgrade it, we skip doing any list insertion or
> deletion and skip to re-calling lm_setup on the existing lease.
> 
> As of commit 8634b51f6ca2 however, we end up calling lm_setup on the
> lease that was passed in, instead of on the existing lease. This causes
> us to leak the fasync_struct that was allocated in the event that there
> was not already an existing one (as it always appeared that there
> wasn't one).
> 
> Fixes: 8634b51f6ca2 (locks: convert lease handling to file_lock_context)

Yes, that fixes the problem. Thanks!

> Reported-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
> Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>

Tested-by: Daniel Wagner <daniel.wagner@bmw-carit.de>


cheers,
daniel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] locks: fix fasync_struct memory leak in lease upgrade/downgrade handling
  2015-03-05  6:57 ` Daniel Wagner
@ 2015-03-05 11:50   ` Jeff Layton
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2015-03-05 11:50 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: linux-fsdevel, linux-kernel, bfields, viro

On Thu, 5 Mar 2015 07:57:09 +0100
Daniel Wagner <daniel.wagner@bmw-carit.de> wrote:

> Hi Jeff,
> 
> On 03/05/2015 01:06 AM, Jeff Layton wrote:
> > Commit 8634b51f6ca2 (locks: convert lease handling to file_lock_context)
> > introduced a regression in the handling of lease upgrade/downgrades.
> > 
> > In the event that we already have a lease on a file and are going to
> > either upgrade or downgrade it, we skip doing any list insertion or
> > deletion and skip to re-calling lm_setup on the existing lease.
> > 
> > As of commit 8634b51f6ca2 however, we end up calling lm_setup on the
> > lease that was passed in, instead of on the existing lease. This causes
> > us to leak the fasync_struct that was allocated in the event that there
> > was not already an existing one (as it always appeared that there
> > wasn't one).
> > 
> > Fixes: 8634b51f6ca2 (locks: convert lease handling to file_lock_context)
> 
> Yes, that fixes the problem. Thanks!
> 
> > Reported-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
> > Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
> 
> Tested-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
> 
> 
> cheers,
> daniel

Thanks for testing it! I'll let it soak in linux-next for a day or so
and then send a pull request to Linus.

Cheers!
-- 
Jeff Layton <jeff.layton@primarydata.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-05 11:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-05  0:06 [PATCH] locks: fix fasync_struct memory leak in lease upgrade/downgrade handling Jeff Layton
2015-03-05  6:57 ` Daniel Wagner
2015-03-05 11:50   ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox