All of lore.kernel.org
 help / color / mirror / Atom feed
From: Seth Forshee <sforshee@digitalocean.com>
To: Christian Brauner <brauner@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>,
	linux-fsdevel@vger.kernel.org, Aleksa Sarai <cyphar@cyphar.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH v2 1/8] mnt_idmapping: add vfs{g,u}id_t
Date: Tue, 21 Jun 2022 13:22:30 -0500	[thread overview]
Message-ID: <YrIMZirGoE0VIO45@do-x1extreme> (raw)
In-Reply-To: <20220621141454.2914719-2-brauner@kernel.org>

On Tue, Jun 21, 2022 at 04:14:47PM +0200, Christian Brauner wrote:
> +/**
> + * kuid_eq_vfsuid - check whether kuid and vfsuid have the same value
> + * @kuid: the kuid to compare
> + * @vfsuid: the vfsuid to compare
> + *
> + * Check whether @kuid and @vfsuid have the same values.
> + *
> + * Return: true if @kuid and @vfsuid have the same value, false if not.
> + */
> +static inline bool kuid_eq_vfsuid(kuid_t kuid, vfsuid_t vfsuid)
> +{
> +	return __vfsuid_val(vfsuid) == __kuid_val(kuid);
> +}

Something that I think would be helpful is if this and other comparison
functions always returned false for comparisons with invalid, e.g.:

static inline bool kuid_eq_vfsuid(kuid_t kuid, vfsuid_t vfsuid)
{
        return vfsuid_valid(vfsuid) && __vfsuid_val(vfsuid) == __kuid_val(kuid);
}

I can't imagine any cases where we would want even two invalid ids to
evaluate as being equal, and so as it is now we have to take great care
to ensure that we never end up with comparisons between two invalid ids.

Honestly I'd like to see that for kuid_t comparisons too, but I suppose
that's a little out of scope here.

Seth

  reply	other threads:[~2022-06-21 18:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21 14:14 [PATCH v2 0/8] introduce dedicated type for idmapped mounts Christian Brauner
2022-06-21 14:14 ` [PATCH v2 1/8] mnt_idmapping: add vfs{g,u}id_t Christian Brauner
2022-06-21 18:22   ` Seth Forshee [this message]
2022-06-22  4:10     ` Christian Brauner
2022-06-21 14:14 ` [PATCH v2 2/8] fs: add two type safe mapping helpers Christian Brauner
2022-06-21 14:14 ` [PATCH v2 3/8] fs: use mount types in iattr Christian Brauner
2022-06-21 14:14 ` [PATCH v2 4/8] fs: introduce tiny iattr ownership update helpers Christian Brauner
2022-06-21 14:14 ` [PATCH v2 5/8] fs: port to " Christian Brauner
2022-06-21 14:14 ` [PATCH v2 6/8] quota: port quota helpers mount ids Christian Brauner
2022-06-21 14:14 ` [PATCH v2 7/8] security: pass down mount idmapping to setattr hook Christian Brauner
2022-06-21 14:14 ` [PATCH v2 8/8] attr: port attribute changes to new types Christian Brauner
2022-06-21 17:33   ` Linus Torvalds
2022-06-22  4:06     ` Christian Brauner
2022-06-23 20:48   ` Seth Forshee
2022-06-23 21:03     ` Christian Brauner
2022-06-23 21:01 ` [PATCH v2 0/8] introduce dedicated type for idmapped mounts Seth Forshee

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=YrIMZirGoE0VIO45@do-x1extreme \
    --to=sforshee@digitalocean.com \
    --cc=brauner@kernel.org \
    --cc=cyphar@cyphar.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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.