The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: syzbot <syzbot+e4470cc28308f2081ec8@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] fs/namespace: fix double hlist_del_init of mnt_mp_list in get_detached_copy()
Date: Fri, 20 Mar 2026 22:53:04 -0700	[thread overview]
Message-ID: <69be3240.050a0220.3bf4de.0040.GAE@google.com> (raw)
In-Reply-To: <69bdce08.050a0220.3bf4de.0031.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] fs/namespace: fix double hlist_del_init of mnt_mp_list in get_detached_copy()
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master


get_detached_copy() builds a new anonymous mount namespace for
open_tree(OPEN_TREE_CLONE) by iterating all mounts in the cloned tree
and calling mnt_add_to_ns() for each. However, child mounts in the
cloned tree have their mnt_mp_list linked into the original mountpoint's
m_list via mnt_set_mountpoint(). mnt_add_to_ns() only updates the
namespace RB tree and never removes mnt_mp_list from that list.

When both the original and new anonymous namespaces are torn down on
process exit, put_mnt_ns() -> umount_tree() -> __umount_mnt() calls
hlist_del_init() on mnt_mp_list for each mount. Since the same mount
belongs to two namespaces, hlist_del_init() is called twice on the same
node, corrupting the list and causing a general protection fault.

Fix this by calling hlist_del_init() on mnt_mp_list and clearing mnt_mp
for each mount inside the loop in get_detached_copy(). This detaches
them from the original mountpoint's m_list. Clearing mnt_mp also
prevents __umount_mnt() from passing a stale pointer to
maybe_free_mountpoint() during teardown.

Reported-by: syzbot+e4470cc28308f2081ec8@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e4470cc28308f2081ec8
Signed-off-by: Deepanshu kartikey <Kartikey406@gmail.com>
---
 fs/namespace.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/namespace.c b/fs/namespace.c
index 854f4fc66469..04e7ffd7fcf5 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3063,6 +3063,10 @@ static struct mnt_namespace *get_detached_copy(const struct path *path, unsigned
 
 	for (p = mnt; p; p = next_mnt(p, mnt)) {
 		mnt_add_to_ns(ns, p);
+		if (p->mnt_mp) {
+			hlist_del_init(&p->mnt_mp_list);
+			p->mnt_mp = NULL;
+		}
 		ns->nr_mounts++;
 	}
 	ns->root = mnt;
-- 
2.43.0


  reply	other threads:[~2026-03-21  5:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 22:45 [syzbot] [fs?] general protection fault in __umount_mnt syzbot
2026-03-21  5:53 ` syzbot [this message]
2026-03-23 15:17 ` Christian Brauner
2026-03-23 15:19   ` syzbot
2026-03-24  8:44   ` Christian Brauner
2026-03-24  9:08     ` syzbot
2026-03-28 13:16 ` syzbot
2026-03-28 21:09   ` Hillf Danton
2026-03-28 21:41     ` syzbot

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=69be3240.050a0220.3bf4de.0040.GAE@google.com \
    --to=syzbot+e4470cc28308f2081ec8@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.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