mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tao Cui <cui.tao@linux.dev>
To: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
	brauner@kernel.org
Cc: jack@suse.cz, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org,
	lxc-devel@lists.linuxcontainers.org, cui.tao@linux.dev,
	Tao Cui <cuitao@kylinos.cn>
Subject: [PATCH] devpts: reject max=0 instead of silently lifting the limit
Date: Thu,  3 Sep 2026 11:36:25 +0800	[thread overview]
Message-ID: <20260903033625.1042796-1-cui.tao@linux.dev> (raw)

From: Tao Cui <cuitao@kylinos.cn>

mount_opts.max == 0 is consumed as ida_alloc_max(..., max - 1), which
wraps to 0xffffffff.  The IDA layer treats a negative max as INT_MAX,
so "mount -t devpts -o max=0" does not disable ptys - it lifts the
per-instance limit entirely and only the global kernel.pty.max still
applies.

Reject the value at parse time:

  $ mount -t devpts -o max=0 pt /tmp/pt
  mount: /tmp/pt: wrong fs type, bad option, bad superblock...

No userspace relies on 0 meaning "unlimited": runc and crun never
set max=, and LXC, the only runtime that does, omits the property
entirely when the configured value is 0.

The value has never been validated since the option was introduced,
so there is no Fixes tag.

Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
 fs/devpts/inode.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index 9844dcf354ee..bd1e8eb26edb 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -249,6 +249,8 @@ static int devpts_parse_param(struct fs_context *fc, struct fs_parameter *param)
 	case Opt_max:
 		if (result.uint_32 > NR_UNIX98_PTY_MAX)
 			return invalf(fc, "max out of range");
+		if (result.uint_32 == 0)
+			return invalf(fc, "max must be greater than 0");
 		opts->max = result.uint_32;
 		break;
 	}
-- 
2.43.0


             reply	other threads:[~2026-09-03  3:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  3:36 Tao Cui [this message]
2026-09-03  4:33 ` Greg KH
2026-09-04 10:57 ` 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=20260903033625.1042796-1-cui.tao@linux.dev \
    --to=cui.tao@linux.dev \
    --cc=brauner@kernel.org \
    --cc=cuitao@kylinos.cn \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lxc-devel@lists.linuxcontainers.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®