linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org
Subject: [bug report] listmount: don't call path_put() under namespace semaphore
Date: Thu, 25 Sep 2025 15:57:43 +0300	[thread overview]
Message-ID: <aNU8RzeIADNri07A@stanley.mountain> (raw)

Hello Christian Brauner,

Commit 59bfb6681680 ("listmount: don't call path_put() under
namespace semaphore") from Sep 19, 2025 (linux-next), leads to the
following Smatch static checker warning:

	fs/namespace.c:5939 __do_sys_listmount()
	warn: pointer dereferenced without being set 'kls.ns'

fs/namespace.c
  5903  static void __free_klistmount_free(const struct klistmount *kls)
  5904  {
  5905          path_put(&kls->root);
  5906          kvfree(kls->kmnt_ids);
  5907          mnt_ns_release(kls->ns);
  5908  }

[ snip ]

    5936 SYSCALL_DEFINE4(listmount, const struct mnt_id_req __user *, req,
    5937                 u64 __user *, mnt_ids, size_t, nr_mnt_ids, unsigned int, flags)
    5938 {
--> 5939         struct klistmount kls __free(klistmount_free) = {};
    5940         const size_t maxcount = 1000000;
    5941         struct mnt_id_req kreq;
    5942         ssize_t ret;
    5943 
    5944         if (flags & ~LISTMOUNT_REVERSE)
    5945                 return -EINVAL;

The __free_klistmount_free() function will dereference kls->ns when it
calls mnt_ns_release() but it's NULL on this path.

    5946 
    5947         /*
    5948          * If the mount namespace really has more than 1 million mounts the
    5949          * caller must iterate over the mount namespace (and reconsider their

regards,
dan carpenter

             reply	other threads:[~2025-09-25 12:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-25 12:57 Dan Carpenter [this message]
2025-09-29  9:33 ` [bug report] listmount: don't call path_put() under namespace semaphore Christian Brauner

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=aNU8RzeIADNri07A@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).