From nobody Mon Dec 1 21:32:50 2025 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 E8B7418FDDE for ; Fri, 28 Nov 2025 03:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764301932; cv=none; b=es89+npeUvDEymXEYb3taEqql/Z4+te7J3TK0ge0Msra+FGaiiqd+LC/eszvDhagSqvKlDBZRgJLDiX6y5QgoY+n7EGnONwnwefC0o2Bi6nIGPUz+jOBtM3SZuS8VBmwsdz+6f7aFpLmii2ICy+4q8YzE+QfZKacFgsYxNzTf2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764301932; c=relaxed/simple; bh=HCOdt9Qo99hBgbc0ASsfVOj8uWEFmoT9+DK8BnZ2g1c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pDSAQ59YfTwDCviUL6BCMLqh78ZMmTmo3zj0MnDzWA4j3Ey1QzpPKhCuQb62EiHDjvEp9SnT3snCpPhCgNm8ctrF8QF3j1+vjbaV053clyRMVgf+6lrlZuVYsHGNDwOYmjs/z9/76AVbqo+t6KJdPkPoUqUWUvmtuEoCF7sPJ/I= 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=jhE7ghey; arc=none smtp.client-ip=209.85.210.169 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="jhE7ghey" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7bf0ad0cb87so1765143b3a.2 for ; Thu, 27 Nov 2025 19:52:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764301929; x=1764906729; 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=3CltxbTuE1mCSM75e6GOL0VL8ptzQXyj6/2m6IZdHiE=; b=jhE7ghey85A4AZ8xSO4EJ3zzL4Y/7QnXmp63NlWVA5s5M0u31rJLBfHKusqBnrJ0u0 fYKYgBIhbr2jz9IwbthdfR4NGoFDLw/s/tHnR2WMyS3YQ92HrV3cRMgKhHxW1f+WAvDg HX+s03PXVeCr3jKVehq5aFYzh4bQObcrY8Uez0TX6J1zzMAR4+pA6Ch7qySklaWqW9kd XcK/k+zLVCs6W6dmrc+CBp+WMDlw9wzWzUrDJ3vdf/l+kNFLO+EwnytstlQp1TlPW7oS TgEfkqB3j8Quhg/AiGpf0GfGbeW5foP/7ResqO6eir9YZroqJFfdhJEpkp8Otzs7iwSX o+ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764301929; x=1764906729; 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=3CltxbTuE1mCSM75e6GOL0VL8ptzQXyj6/2m6IZdHiE=; b=wX3dwwYL/5K1dDwVqyz5Wcu0jzpiKcgmJkLareHzrp3PF7EXQgEVzR6+T3zuJxNkCc TkxVejBo61GdFtK3KWrJ8Y8FFuTEw9G9CymJd4+5Dm1Er8TBaXKACOJ1xmQhmP8Rm1RV ofsO/ewkSDOLuTE87tJlB997pWVSCzmZkrd+PJZi0V2KY6vZJVJ/ipm8VLmzVD1P/XIO kirqxxqrjiOvCl76eRNSQgG/fwct8+zR2hjMVeoSY6dBXCO/9kWoUmAkWYs/toySdWxB DQDRoX+uiuZ06iYhTMWBMqORFMLII9V0MrRYjutUMAJX/23l/86/l88JkUTmDex3eQiS vgRg== X-Forwarded-Encrypted: i=1; AJvYcCX1W/Qpv+ugOxMX0j0LVBzlL46D+kG/wjlSPj06O0ntkwZsLtdv5maebTc9qs1aLdTKbKAtQ8zzfubV1ic=@vger.kernel.org X-Gm-Message-State: AOJu0YyoZqcv/icJdVDQoEagCCr0H1g+C8xRrAGK/9g9ZiSh94A46Vja ciQ0XO3D2YedKIQ8KfPNpNPmY7ksaEyYU7q39Gm8udy+a8yue2HKUwKC X-Gm-Gg: ASbGncuB4G2n+A40ukZVyfbcCfywS39LVlDFm5YJxxKJo6yhDglK+q1NlPSnDDDbqRo ygkeYf1yNcmYYP4Cmdgma9BaRSXAC96gY8lI/H0ulhU6CiSQIbdhy+tsPrW2F0D49sl7od0qppu xL4CnS2TCZVsOaJ/Y4J7QuRz8OGiSxGXN3Mod7X9VdV+YjYkI2S9RMj204eAiuA00Z3S8TiU27+ pU6JjzGFUjde4aOEB6aNANoG8r7sU/TXTwWjHesbYeYBrQnvZMV3KzddhrY70iG9VIY+KR84BPo O5ONe9ifqpgqtkmrt6o8QCPC/d1c3qO8IyqfnJET9LxnebhrZ5fXa62mw8na0/R8HTHO3L35WU3 iPF4NOnjTVAib5hr5Mz5BfgiwHAdf0W3GWsUoiycz4VOuD9tCXIm+mjxsTrUwl6tyBwNnJzDSn2 Bsmaoup7BnfF7RInotKKcR5O0xV1nsil/5Ajs= X-Google-Smtp-Source: AGHT+IGOZUJSqSaUAsFfUtC3iidI2uyYilieUl+dVyyfoh7INnYHEIe9kYoy7b8hsG9r/zdplWPNIQ== X-Received: by 2002:a05:6a00:12e1:b0:7ba:2efc:7b3f with SMTP id d2e1a72fcca58-7c58beb6412mr24314905b3a.5.1764301929136; Thu, 27 Nov 2025 19:52:09 -0800 (PST) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:389d:fa57:54bd:ea3b:1d14]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15fd01c3csm3290008b3a.69.2025.11.27.19.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Nov 2025 19:52:08 -0800 (PST) From: Deepanshu Kartikey To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Deepanshu Kartikey , syzbot+94048264da5715c251f9@syzkaller.appspotmail.com Subject: [PATCH] fs/namespace: fix mntput of ERR_PTR in fsmount error path Date: Fri, 28 Nov 2025 09:21:48 +0530 Message-ID: <20251128035149.392402-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" When vfs_create_mount() fails and returns an error pointer, the __free(path_put) cleanup attribute causes path_put() to be called on the error pointer, which then calls mntput() on an invalid pointer value (e.g., -ENOENT =3D 0xfffffffffffffff4). This results in a general protection fault in mntput() when KASAN tries to check the shadow memory for the near-null address computed from the error pointer offset. Fix this by clearing newmount.mnt to NULL after extracting the error code, preventing the path_put cleanup from operating on the error pointer. Reported-by: syzbot+94048264da5715c251f9@syzkaller.appspotmail.com Tested-by: syzbot+94048264da5715c251f9@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D94048264da5715c251f9 Fixes: 67c68da01266 ("namespace: convert fsmount() to FD_PREPARE()") Signed-off-by: Deepanshu Kartikey --- fs/namespace.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index e5240df614de..236482fd503f 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4343,8 +4343,11 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, f= lags, warn_mandlock(); =20 newmount.mnt =3D vfs_create_mount(fc); - if (IS_ERR(newmount.mnt)) - return PTR_ERR(newmount.mnt); + if (IS_ERR(newmount.mnt)) { + ret =3D PTR_ERR(newmount.mnt); + newmount.mnt =3D NULL; + return ret; + } newmount.dentry =3D dget(fc->root); newmount.mnt->mnt_flags =3D mnt_flags; =20 --=20 2.43.0