All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yichong Chen <chenyichong@uniontech.com>
To: gregkh@linuxfoundation.org
Cc: jirislaby@kernel.org, viro@zeniv.linux.org.uk,
	willy@infradead.org, kees@kernel.org,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] devpts: fix pty count limit off by one
Date: Tue,  4 Aug 2026 17:52:52 +0800	[thread overview]
Message-ID: <20260804095252.889108-1-chenyichong@uniontech.com> (raw)
In-Reply-To: <2026080419-chatting-curve-e49c@gregkh>

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

  reply	other threads:[~2026-08-04  9:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04  8:23 [PATCH] devpts: fix pty count limit off by one Yichong Chen
2026-08-04  8:40 ` Greg KH
2026-08-04  9:52   ` Yichong Chen [this message]
2026-08-04 10:06     ` Greg KH

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=20260804095252.889108-1-chenyichong@uniontech.com \
    --to=chenyichong@uniontech.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.