mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>,
	linux-fsdevel@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-api@vger.kernel.org, Dave Chinner <dchinner@redhat.com>
Subject: Re: Testing if two open descriptors refer to the same inode
Date: Mon, 29 Jul 2024 14:26:17 +0200	[thread overview]
Message-ID: <20240729-respekt-tonnen-9c8f6c4d3bff@brauner> (raw)
In-Reply-To: <ghqndyn4x7ujxvybbwet5vxiahus4zey6nkfsv6he3d4en6ehu@bq5s23lstzor>

On Mon, Jul 29, 2024 at 12:18:15PM GMT, Mateusz Guzik wrote:
> On Mon, Jul 29, 2024 at 08:55:46AM +0200, Florian Weimer wrote:
> > It was pointed out to me that inode numbers on Linux are no longer
> > expected to be unique per file system, even for local file systems.
> 
> I don't know if I'm parsing this correctly.
> 
> Are you claiming on-disk inode numbers are not guaranteed unique per
> filesystem? It sounds like utter breakage, with capital 'f'.
> 
> I know the 32-bit inode allocation code can result in unintentional
> duplicates after wrap around (see get_next_ino), but that's for
> in-memory stuff only(?) like pipes, so perhaps tolerable.
> 
> Anyhow, the kernel recently got F_DUPFD_QUERY which tests if the *file*
> object is the same.
> 
> While the above is not what's needed here, I guess it sets a precedent
> for F_DUPINODE_QUERY (or whatever other name) to be added to handily
> compare inode pointers. It may be worthwhile regardless of the above.
> (or maybe kcmp could be extended?)

We don't use kcmp() for such core operations. It's overkill and security
sensitive so quite a few configs don't enable it. See [1] for details
how kcmp() can be used to facilitate UAF attacks and defeat
probabilistic UAF mitigations by using ordering information. So that
ordering requirement should really go out the window.

Another thing is that kcmp() works cross-process which is also out of
scope for this. kcmp() really should be reserved for stuff that
checkpoint/restore in userspace needs and that's otherwise too fruity to
be implemented in our regular apis.

[1]: https://googleprojectzero.blogspot.com/2021/10/how-simple-linux-kernel-memory.html

  parent reply	other threads:[~2024-07-29 12:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29  6:55 Florian Weimer
2024-07-29  9:09 ` Aleksa Sarai
2024-07-29  9:29   ` Florian Weimer
2024-07-29 10:18 ` Mateusz Guzik
2024-07-29 10:40   ` Florian Weimer
2024-07-29 10:50     ` Mateusz Guzik
2024-07-29 10:56       ` Mateusz Guzik
2024-07-29 10:57       ` Florian Weimer
2024-07-29 11:06         ` Mateusz Guzik
2024-07-29 11:36           ` Florian Weimer
2024-07-29 12:00             ` Mateusz Guzik
2024-07-29 11:40           ` Aleksa Sarai
2024-07-31 18:07             ` David Sterba
2024-07-29 11:47           ` Aleksa Sarai
2024-07-29 12:12             ` Mateusz Guzik
2024-07-29 23:19               ` Dave Chinner
2024-07-29 23:08         ` Dave Chinner
2024-07-29 12:26   ` Christian Brauner [this message]
2024-07-29 13:36   ` Theodore Ts'o
2024-07-30  2:31     ` Dave Chinner
2024-07-30  4:19       ` Theodore Ts'o
2024-07-30 15:38       ` Christoph Hellwig
2024-07-29 15:24 ` Jeff Layton
2024-07-29 15:39   ` Florian Weimer

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=20240729-respekt-tonnen-9c8f6c4d3bff@brauner \
    --to=brauner@kernel.org \
    --cc=dchinner@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    /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

all inboxes | Powered by JetHome®