mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] devpts: reject max=0 instead of silently lifting the limit
@ 2026-09-03  3:36 Tao Cui
  2026-09-03  4:33 ` Greg KH
  2026-09-04 10:57 ` Christian Brauner
  0 siblings, 2 replies; 3+ messages in thread
From: Tao Cui @ 2026-09-03  3:36 UTC (permalink / raw)
  To: linux-fsdevel, viro, brauner
  Cc: jack, gregkh, linux-kernel, lxc-devel, cui.tao, Tao Cui

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-04 10:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-03  3:36 [PATCH] devpts: reject max=0 instead of silently lifting the limit Tao Cui
2026-09-03  4:33 ` Greg KH
2026-09-04 10:57 ` Christian Brauner

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®