The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Josef Bacik <josef@bacik.io>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Christian Brauner <brauner@kernel.org>,
	driver-core@lists.linux.dev, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernfs: don't take a failed id allocation for a wrap
Date: Thu, 03 Dec 2026 09:13:52 -1000	[thread overview]
Message-ID: <760de4526e0b26bde176bf952ed3360c@kernel.org> (raw)
In-Reply-To: <20261202-b4-kernfs-id-wrap-v1-1-99d9a77c1300@bacik.io>

On Wed, Dec 02, 2026 at 02:40:46PM -0500, Josef Bacik wrote:
> After one failed id allocation every new node of that kernfs root gets an
> inode number above 32 bits on a 64 bit kernel, and the 32 bit stat() and
> getdents() fail on it with EOVERFLOW until the root goes away.
>
> __kernfs_new_node() stores the result of idr_alloc_cyclic() in the u32
> last_id_lowbits even when it is an errno. The next id is below that
> value, so id_highbits is incremented as if the low bits had wrapped.
>
> Reproduced with failslab on radix_tree_node while making cgroups, the
> inode number of the first cgroup made after the ENOMEM:
>
>     before: 0x1000002c0
>     after:  0x2c0
>
> Getting the last id once more is a wrap as well, and the stored errno
> covered for that after an ENOSPC.
>
> Fix by only recording ids that were allocated, and by counting an id
> equal to the last one as a wrap.
>
> Fixes: e23f568aa63f ("kernfs: fix ino wrap-around detection")
> Signed-off-by: Josef Bacik <josef@bacik.io>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

--
tejun

      reply	other threads:[~2026-12-03 19:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 19:40 [PATCH] kernfs: don't take a failed id allocation for a wrap Josef Bacik
2026-12-03 19:13 ` Tejun Heo [this message]

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=760de4526e0b26bde176bf952ed3360c@kernel.org \
    --to=tj@kernel.org \
    --cc=brauner@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=josef@bacik.io \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox