From nobody Sat Apr 4 01:33:32 2026 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE459368263 for ; Sat, 21 Mar 2026 06:24:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774074264; cv=none; b=EvKhHOAZMFW0vCFNOmTBkhQF7Xru0jJx3xEWH3EPFjSgu5svWcyzmT66ZBaCtKgYqvGRN3HdwuqZq+tRhcLAUQkH0KzQYESeiJTjQ2Xj3Dg+7+lqRoilsAs4cF86+2gu0tnCjp50Tb+dLmRgC60VrNsHQqCragYgdvbdlYfITIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774074264; c=relaxed/simple; bh=nTO2Gx3WmvdiBOjCFsXe13z/HKMaS7yzJD5EwSY0wSQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JlrSxsKl7ZdQ1GltLN9kzn2XA04VOmtvBLPXTt+iYAnHHiBFnObfyBQTHi+d0SjiGjwJy7F0jgZqlSdXDlC8cak6lyx0UcpX+xneW//swwZYJMC3xpZmvvN4LfwmR4E0kLvVVY3a+SrFZysu23LzDAnjg0SX+hfbfi9Dx3e/jFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RoofpU0Z; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RoofpU0Z" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-82be8702db6so513237b3a.2 for ; Fri, 20 Mar 2026 23:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774074261; x=1774679061; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OaQRGRXsvJkENa/hzfE98pz3839YGIUuM6KjI5vU0xQ=; b=RoofpU0ZHoTqd5WCgDFNPsLF53p7H6PlKtbfTRwwmmF8t6qwwpIEmZPg2Ye67c7CX1 wiqdd7miwhhYtVGSM5J9fw2oDiZtCEsSvYE8u/FCRfMmiY9xv5t5CU4zod1y7z8qT9U2 062olCAErMCj69E5aKQJBk0pg2McS2UYmk1dXn+ATzQe5l1mJAG14dcA6l0tF9hR0WfP GqieCNuK7HWPxiX+WxxSDvrA9CXeyIkob5KfwhWwp5upYlbe4yrXvyRJl0GW5Yb6o06k yAr4suSPh1TfnvM7NtfBxLn5vBGgRIdUOWJanejEd7Z7QdP3FlLH32rXR5rB0daqSOKd I3Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774074261; x=1774679061; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OaQRGRXsvJkENa/hzfE98pz3839YGIUuM6KjI5vU0xQ=; b=dqhKyXi4znk4HAhWQz5YXfcmvVmaGWbTq3tQwA/ZGXDo35Ufg3NXAXOqjtQeIrCv3M pFxIpt+m6CLVN+qNxcCyiRmIgZqRnN7gPluGt9zqwH0rxo1ZIhHjxdylID+es6EkIIJK cGWxA7ING+2PrS6g86MOp4Nz7nYP3FXK1zOZKu04YeCr6t1xKfGQJJ5hi0701E2h2feG rjl8/AQda/pskqK2daMb6P8Ii9nTHEGoeI2pSSzLmk0K0NHq6RXumKQLbeVryXmR4cF/ k5v6BGsG+BOvHzEMJfLUHBG8RNRM+yWJXmtkD1vzRJSNungsPOhGUgJS/6hJQhJ7/NxY F7gg== X-Forwarded-Encrypted: i=1; AJvYcCXzYUd0QlBuv2qrPkX1AGadw2meThj6aIbCv6VhP5AStFWdQyygTxLXK0y1+dGgTERsXNp/CltZicJdJzA=@vger.kernel.org X-Gm-Message-State: AOJu0YwJX30yhiyiowmeTMIPrdTjUNhktKK6aCtC1jn69Cz6rqpeN7yN 8FZ4xEidNFD3Cwq3FOxienuYNBwXHuFTe9WV2DxUbqRl8RlOkOytgR3o X-Gm-Gg: ATEYQzyCC0DcbJ1+MEoa8gnrNiUyFU6LK+MXgbQ426FPysH/HwXJWG/fxM1JbjIYHN3 uB86wmJIS5+8PIGy4QbZxJb3DMbz1d5bNFm0hfUDrH/FDQ1cmEdvwicw4mVlWR9gv7KOK64iqWm 3nLesiwTCaD5ex2ZrGEWvXI7LBmiDnJ5IZBnKQPX3lvIyaKI0rrYOZUMBMVtweSopo+Lw+jrZlx k18aWpRChtR1+F04sNZsVmOm9+r8LhOlj/x/MbLlwmwPOteP1stmVH7WQpeIYpGyDaQ4j18+ftM oUmvVEOOxGko2AKRb7LoHZQwaxCrEDEguDkQHWY1xvahzyLXd6XxPmK/7GDzWyIGhyvYllTArAX Tvp+UfdLF4AAV5vnIv0s1oLRxEUXaPC9OEkl9RzZHhLjAdTSf2YCgp7GsIl6ZMw/6CzEFOeykDV lcj+5RPHbbgPG/VaQ2tC/DrZmfeJ0XUn4KRwAaLIt9FAIsPvRolAEJ9BP96sQDdphgMch5BKTQl SAJRF4wc3lHSyCZbw== X-Received: by 2002:a05:6a00:9510:b0:82a:609f:d49c with SMTP id d2e1a72fcca58-82a8c35de95mr4326831b3a.47.1774074260765; Fri, 20 Mar 2026 23:24:20 -0700 (PDT) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:389d:5c27:b800:7775:1147]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82b0409bf65sm3676997b3a.34.2026.03.20.23.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 23:24:20 -0700 (PDT) From: Deepanshu Kartikey To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz Cc: mszeredi@redhat.com, raven@themaw.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Deepanshu Kartikey , syzbot+e4470cc28308f2081ec8@syzkaller.appspotmail.com, Deepanshu kartikey Subject: [PATCH] fs/namespace: fix double hlist_del_init of mnt_mp_list in get_detached_copy() Date: Sat, 21 Mar 2026 11:54:12 +0530 Message-ID: <20260321062412.1120693-1-kartikey406@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3De4470cc28308f2081ec8 Tested-by: syzbot+e4470cc28308f2081ec8@syzkaller.appspotmail.com Fixes: 2eea9ce4310d ("mounts: keep list of mounts in an rbtree") Signed-off-by: Deepanshu kartikey --- 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 =20 for (p =3D mnt; p; p =3D next_mnt(p, mnt)) { mnt_add_to_ns(ns, p); + if (p->mnt_mp) { + hlist_del_init(&p->mnt_mp_list); + p->mnt_mp =3D NULL; + } ns->nr_mounts++; } ns->root =3D mnt; --=20 2.43.0