mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Cai Xinchen <caixinchen1@huawei.com>, <jmorris@namei.org>,
	<serge@hallyn.com>, <amir73il@gmail.com>, <brauner@kernel.org>,
	<caixinchen1@huawei.com>
Cc: <linux-security-module@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <lujialin4@huawei.com>
Subject: Re: [PATCH v2 2/2] security: Fix call security_backing_file_free  second time
Date: Thu, 27 Aug 2026 12:30:58 -0400	[thread overview]
Message-ID: <e7bf759345415ea1935fc845506d84d9@paul-moore.com> (raw)
In-Reply-To: <20260707080615.1235830-3-caixinchen1@huawei.com>

On Jul  7, 2026 Cai Xinchen <caixinchen1@huawei.com> wrote:
> 
> I found the following path:
> 
> alloc_empty_backing-file
>     init_file(&ff->file, xxx)
>         -> file_ref_init(&f->f_ref, 1); // only 1
>     error = init_backing_file
>         -> security_backing_file_alloc
>         -> rc = call_int_hook(backing_file_alloc, ...)
>            if (unlikely(rc))
>            	security_backing_file_free(backing_file); // first call
>     if (unlikely(error)) {
>         fput(&ff->file);
>          -> if (unlikely(file_ref_put(&file->f_ref))) // zero
>                 __fput_deferred(file);
>                  -> ____fput -> __fput -> file_free(file);
>                  -> backing_file_free(backing_file(f));
>                  -> security_backing_file_free(&ff->file); // second call
> 
> Currently, only SELinux has the lsm backing_file_alloc hook, and it always
> return 0. When security_backing_file_free is called for the first time,
> the blobs pointer is set to NULL. Therefore, double free will not occur in
> the code.
> 
> Fixes: 6af36aeb147a ("lsm: add backing_file LSM hooks")
> Signed-off-by: Cai Xinchen <caixinchen1@huawei.com>
> ---
>  security/security.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Merged into lsm/dev-staging, will be moved to lsm/dev after the merge
window.

--
paul-moore.com

  reply	other threads:[~2026-08-27 16:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07  8:06 [PATCH v2 -next 0/2] " Cai Xinchen
2026-07-07  8:06 ` [PATCH v2 -next 1/2] security: Delete dumplicate assignment Cai Xinchen
2026-08-27 16:30   ` [PATCH v2 " Paul Moore
2026-08-31 21:28     ` Paul Moore
2026-07-07  8:06 ` [PATCH v2 -next 2/2] security: Fix call security_backing_file_free second time Cai Xinchen
2026-08-27 16:30   ` Paul Moore [this message]
2026-08-31 21:29     ` [PATCH v2 " Paul Moore

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=e7bf759345415ea1935fc845506d84d9@paul-moore.com \
    --to=paul@paul-moore.com \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=caixinchen1@huawei.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=lujialin4@huawei.com \
    --cc=serge@hallyn.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®