Re: [PATCH] devpts: fix pty count limit off by one

Yichong Chen <[email protected]>
Newsgroups gmane.linux.serial,gmane.linux.kernel
Message-ID <[email protected]>
Hi Greg,

Yes, this is user-visible.

The reason I sent the patch is that this used to allow pty_count to reach
the configured limit.  Before commit 0f0a0e54a2a1 ("devpts: Convert to new
IDA API"), devpts_new_index() checked the old pty_count first and only
incremented it after the allocation succeeded:

  if (pty_count >= limit)
          return -ENOSPC;
  ...
  pty_count++;

After that commit, the code started using atomic_inc_return(), but kept the
>= comparison:

  if (atomic_inc_return(&pty_count) >= limit)
          goto out;

So a count equal to the configured limit became rejected.  That makes
kernel.pty.max behave as an effective max - 1 limit.

I thought allowing the count to reach kernel.pty.max again would better
match the usual interpretation of a "max" sysctl.  But I agree this also
changes visible behavior again, and the current max - 1 behavior has been
around since 2018.

So if you prefer to preserve the existing behavior for compatibility, I am
fine with dropping the patch.

Thanks,
Yichong
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.