From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 D98EB34D4EB for ; Fri, 13 Feb 2026 09:38:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770975532; cv=none; b=qDZ+A2+oLyun37tar5cjSEbM46cn5+14BGPXE4eRKfVshYFJRKNR/tIJ1XxeT9Ji6zZV0qsmTpYlZ62JlvTWuLFXmVKwPSsBNYPH9s9UDio8ASI6bD5zw2JkdC798qfy8l0N8OKOSW0+Isg0+QyfG5awt9wvTH16kWUf3ct4nNE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770975532; c=relaxed/simple; bh=qRk0XbgqqkHbS1K5VlJc19rLQpxSWv7j9+VNx/G3fnY=; h=Mime-Version:Content-Type:Date:Message-Id:From:To:Cc:Subject: References:In-Reply-To; b=KjdIRO0KSgikcydNr2UQKWYqBMCrwTcTWZSDLkflsL27PUEVG63wqWydkSPMzewkFF2eS3Kl6h9ufpW3Ie8+WZfJ5/wPLaExtDCY8HHBYo42bAfUitrvBUD5eAup1KFfh417to68Qug6PyW/G3cQPXx5gc43XMU3siaBsLROSOg= 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=AgxbO7XL; arc=none smtp.client-ip=209.85.210.173 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="AgxbO7XL" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-824c9da9928so208752b3a.3 for ; Fri, 13 Feb 2026 01:38:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770975531; x=1771580331; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6r2feZNNUcf548IzTebf5d7uh7AISHSV/SqdlNPNXAQ=; b=AgxbO7XLrW/tCW+Tr5cP7eOdr2Wo6zcTY+c/qj7i3oS7IQH7HXab+MLdb1nPTWz0KO 6+GPlxrXtjP3E73MphVvdZ55HDPkJX6dKaThVfp+schP2jqnLnGy2nZPdg3dFlln5f2k PE6In9XaVn7cZqqCtkEuD6CLQ66JcFTlj4Ti5bvO2bOoPA4OPW28/c8Rryj1qlBYJzpm TPtEWaOHqJVX+vGR7cCZMtQUFKe+e8mM0BUeo1lV7irHEPTOeLyTsFgETnFQBw7AzGIy LhMXOFqED7nPy+KNu0ZMAOEuZLL3d8e3+xB057IispbAzAx8DtaS7uxlf7YkX1/KpdwI Lz6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770975531; x=1771580331; h=in-reply-to:references:subject:cc:to:from:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=6r2feZNNUcf548IzTebf5d7uh7AISHSV/SqdlNPNXAQ=; b=QJDQVbtZx1Hl/yczhWR4xqBRLKJr3OfKkWq3Ei3jxrC++OsSZUDOlZRSVcveJYDNj3 0vDvi2J0ciWBuXwS4KauqVncyA4EEg1dn1wX2UmbqvZdD+fOU+VRrkTfGoo55OdQJ6uG DFXw0NgN46s/zgi47pTPGMI+xXkbtSmcepsdyP/8nz3L+Sdz7dp/rFl8hz7dQ5DZKWSl ZwpBdSHlGGcm07jfL2dptzOPSqVIJlfH27TevjIzEOe9DN1bmDf2SQa1WOBT+XV285xi pdrBNiqQCjeyAiZwdXhjUsb+HOJNBYKSLqZS3tXHgQhjaVVxhkDm5ebI1X6TvzHvUNRN VVxg== X-Forwarded-Encrypted: i=1; AJvYcCWHAmXJSnrA8iscy/AB+CqE0lZBizoPLahxOWUIGA6/Ko+GgAciGuD/GXDYf4Vk19cILw7R1YsIyu8kncE=@vger.kernel.org X-Gm-Message-State: AOJu0YwoSxrsqTLCvCq1FDPm2gHNjVMOQYVyTg0ZzClqQFv5z+7NgD+7 0OUSmxuJ3iEBYnzbmRNNpJ2p6xA9AhP1HJ+dqK4yJ3wDZFqnI9U3y+9P X-Gm-Gg: AZuq6aLzvtaocg0AZ/2nBa6cGMVdfx3SvkkCnVgtB+80snyuJlFWLkMueoUdKo4D9aY zDxZafIyY0lY9MernV7goih+0IX2e5MgtBbZ1g4JXsEJ6rwJi0MX6D4actAyEBoLAZmIAV+1PUa 3ySFVUzWvfK7pb6l3R5aBNbl+5nZUN0egaC312Ve4mxnTx25/vVuMwMx7voNodRHrpWcdWpZ2Yz 7qtODOJqACfZlZXolVyvbsr/2RzVeb0+xSCHgq2toa8nzH8w0gSWZbjyRcbuATwB2QFMAaqQAtx Kz3KgX1IENX9BitaDysxIvWJtqUz2vPg87XoFEe+kt7/YYfJWIQc61rpL8l8XYtr4yrUS/uQbh3 a5ZXGHME90mm6I3esWboOy2X7J+Q2+IG2WgpH8vCj75RPH3NvFCtC7uxHIefVBV8jkX7e2kyXvK FvuIzsWrPubbiv9wgo2vrgQ0dof9AEho+EUZX7KuynY3Z3kAutYfwQVzpPxkA= X-Received: by 2002:a05:6a21:918b:b0:38e:883f:694d with SMTP id adf61e73a8af0-3946c79cfdamr1391165637.24.1770975531048; Fri, 13 Feb 2026 01:38:51 -0800 (PST) Received: from localhost ([2405:201:3017:184:52f5:ed80:f874:1efc]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c6e196a8eb2sm7095318a12.11.2026.02.13.01.38.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Feb 2026 01:38:50 -0800 (PST) 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 Date: Fri, 13 Feb 2026 15:08:44 +0530 Message-Id: From: "Bhavik Sachdev" To: "Qing Wang" , "Alexander Viro" , "Christian Brauner" , "Jan Kara" , "Pavel Tikhomirov" , "Bhavik Sachdev" , "Andrei Vagin" Cc: , , Subject: Re: [PATCH] statmount: Fix the null-ptr-deref in do_statmount() X-Mailer: aerc 0.21.0 References: <20260213084259.2423971-1-wangqing7171@gmail.com> In-Reply-To: <20260213084259.2423971-1-wangqing7171@gmail.com> On Fri Feb 13, 2026 at 2:12 PM IST, Qing Wang wrote: > If the mount is internal, it's mnt_ns will be MNT_NS_INTERNAL, which is > defined as ERR_PTR(-EINVAL). So, in the do_statmount(), need to check ns > of mount by IS_ERR_OR_NULL(). > > Fixes: 0e5032237ee5 ("statmount: accept fd as a parameter") > Reported-by: syzbot+9e03a9535ea65f687a44@syzkaller.appspotmail.com > Closes: https://lore.kernel.org/all/698e287a.a70a0220.2c38d7.009e.GAE@goo= gle.com/ > Tested-by: syzbot+9e03a9535ea65f687a44@syzkaller.appspotmail.com > Signed-off-by: Qing Wang > --- > fs/namespace.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/fs/namespace.c b/fs/namespace.c > index a67cbe42746d..d769d50de5d6 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c > @@ -5678,13 +5678,15 @@ static int do_statmount(struct kstatmount *s, u64= mnt_id, u64 mnt_ns_id, > =20 > s->mnt =3D mnt_file->f_path.mnt; > ns =3D real_mount(s->mnt)->mnt_ns; > - if (!ns) > + if (IS_ERR_OR_NULL(ns)) { > /* > * We can't set mount point and mnt_ns_id since we don't have a > * ns for the mount. This can happen if the mount is unmounted > - * with MNT_DETACH. > + * with MNT_DETACH or if it's an internal mount. > */ > s->mask &=3D ~(STATMOUNT_MNT_POINT | STATMOUNT_MNT_NS_ID); > + ns =3D NULL; > + } > } else { > /* Has the namespace already been emptied? */ > if (mnt_ns_id && mnt_ns_empty(ns)) Hey! I think the fix should be the following instead, AFAIU we don't want a call to an internal mount to succeed. diff --git a/fs/namespace.c b/fs/namespace.c index a67cbe42746d..55152bf64785 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -5678,6 +5678,8 @@ static int do_statmount(struct kstatmount *s, u64 mnt= _id, u64 mnt_ns_id, s->mnt =3D mnt_file->f_path.mnt; ns =3D real_mount(s->mnt)->mnt_ns; + if (IS_ERR(ns)) + return -EINVAL; if (!ns) /* * We can't set mount point and mnt_ns_id since we = don't have a Thanks, Bhavik