All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Elizabeth Figura <zfigura@codeweavers.com>
Cc: linux-fsdevel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] fix a file reference leak in drivers/misc/ntsync.c
Date: Wed, 15 Jan 2025 19:43:23 +0100	[thread overview]
Message-ID: <2025011504-thong-irritate-4bf4@gregkh> (raw)
In-Reply-To: <12598856.O9o76ZdvQC@camazotz>

On Wed, Jan 15, 2025 at 12:20:34PM -0600, Elizabeth Figura wrote:
> On Tuesday, 14 January 2025 20:50:02 CST Al Viro wrote:
> > 	struct ntsync_obj contains a reference to struct file
> > and that reference contributes to refcount - ntsync_alloc_obj()
> > grabs it.  Normally the object is destroyed (and reference
> > to obj->file dropped) in ntsync_obj_release().  However, in
> > case of ntsync_obj_get_fd() failure the object is destroyed
> > directly by its creator.
> > 
> > 	That case should also drop obj->file; plain kfree(obj)
> > is not enough there - it ends up leaking struct file * reference.
> > 
> > 	Take that logics into a helper (ntsync_free_obj()) and
> > use it in both codepaths that destroy ntsync_obj instances.
> > 
> > Fixes: b46271ec40a05 "ntsync: Introduce NTSYNC_IOC_CREATE_SEM"
> > Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> > ---
> 
> Reviewed-by: Elizabeth Figura <zfigura@codeweavers.com>
> 
> 
> ---
> 
> Thanks for catching this. There's a similar problem with the other newly introduced object types in the char-misc-next tree (and this patch doesn't apply cleanly there anyway). I'll send a similar patch for those, unless you have one already.

I already applied this and fixed up the fuzz there, it's now running
through 0-day testing...

thanks,

greg k-h

      reply	other threads:[~2025-01-15 18:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-15  2:50 [PATCH] fix a file reference leak in drivers/misc/ntsync.c Al Viro
2025-01-15 18:20 ` Elizabeth Figura
2025-01-15 18:43   ` Greg Kroah-Hartman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2025011504-thong-irritate-4bf4@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zfigura@codeweavers.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.