Linux filesystem development
 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 related	[flat|nested] 3+ messages in thread

* Re: [PATCH] devpts: reject max=0 instead of silently lifting the limit
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-09-03  4:33 UTC (permalink / raw)
  To: Tao Cui
  Cc: linux-fsdevel, viro, brauner, jack, linux-kernel, lxc-devel,
	Tao Cui

On Thu, Sep 03, 2026 at 11:36:25AM +0800, Tao Cui wrote:
> 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.

Shouldn't the Fixes tag be where the option was introduced?

Anyway, not all that big of a deal as this is a root-only thing.

thanks,

greg k-h

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

* Re: [PATCH] devpts: reject max=0 instead of silently lifting the limit
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2026-09-04 10:57 UTC (permalink / raw)
  To: linux-fsdevel, viro, Tao Cui
  Cc: jack, gregkh, linux-kernel, lxc-devel, Tao Cui

On Thu, 03 Sep 2026 11:36:25 +0800, Tao Cui wrote:
> devpts: reject max=0 instead of silently lifting the limit

I'll figure out the Fixes tag.

---

Applied to the vfs-7.4.misc branch of the vfs/vfs.git tree.
Patches in the vfs-7.4.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.4.misc

[1/1] devpts: reject max=0 instead of silently lifting the limit
      https://git.kernel.org/vfs/vfs/c/7d1d1a34d29c


^ 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