linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: "Christian Göttsche" <cgzones@googlemail.com>
Cc: Aleksa Sarai <cyphar@cyphar.com>,
	Christian Brauner <brauner@kernel.org>,
	SElinux list <selinux@vger.kernel.org>,
	Miklos Szeredi <mszeredi@redhat.com>,
	Linux API <linux-api@vger.kernel.org>,
	linux-man <linux-man@vger.kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] f*xattr: allow O_PATH descriptors
Date: Fri, 19 Aug 2022 23:27:49 +0300	[thread overview]
Message-ID: <CAOQ4uxhiyVixjDnDsMusfAPqP4DkbA0TfmOKGLa_L6T6s1JJjQ@mail.gmail.com> (raw)
In-Reply-To: <CAJ2a_DfkMvh7EdOA6k+omxhi18-oVbSXSGzXnpU1tXPD55B2qw@mail.gmail.com>

On Fri, Aug 19, 2022 at 9:05 PM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> On Wed, 22 Jun 2022 at 04:57, Aleksa Sarai <cyphar@cyphar.com> wrote:
> >
> > On 2022-06-20, Amir Goldstein <amir73il@gmail.com> wrote:
> > > To be a reasonable reaction to the currently broken API is
> > > to either accept the patch as is or request that setxattrat()
> > > will be added to provide the new functionality.
> >
> > Since the current functionality cannot be retroactively disabled as it
> > is being used already through /proc/self/fd/$n, adding
> > *xattrat(AT_EMPTY_PATH) doesn't really change what is currently possible
> > by userspace.
> >
> > I would say we should add *xattrat(2) and then we can add an upgrade
> > mask blocking it (and other operations) later.
> >
>
> It seems setxattrat() is the preferred way to continue.
> fsetxattr() would have one advantage though (w.r.t. SELinux):
>
> The steps to label a file are:
>   1. get the type of the file (via stat(2) family)
>   2. lookup the desired label from the label database via selabel_lookup(3)
>   3. assign the retrieved label to the file
>
> The label is sensitive to the file type, e.g.
>
>     $ matchpathcon -m file /etc/shadow
>     /etc/shadow     system_u:object_r:shadow_t:s0
>     $ matchpathcon -m lnk_file /etc/shadow
>     /etc/shadow     system_u:object_r:etc_t:s0
>
> Using the *at() family the file type could change between step 1. and 3.,
> which operating on an O_PATH file descriptor would prevent.

I don't understand the problem.

If you have an O_PATH fd, the object it represents does not change.
If you use fstatat(fd, ..., AT_EMPTY_PATH) (or fstat) and
setxattrat(fd, ..., AT_EMPTY_PATH), it prevents the race.

Thanks,
Amir.

  reply	other threads:[~2022-08-19 20:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07 15:31 [RFC PATCH] f*xattr: allow O_PATH descriptors Christian Göttsche
2022-06-08  5:13 ` Amir Goldstein
2022-06-08 11:27 ` Christian Brauner
2022-06-08 12:28   ` Amir Goldstein
2022-06-08 12:48     ` Christian Brauner
2022-06-08 15:12       ` Amir Goldstein
2022-06-09  8:56         ` Christian Brauner
2022-06-18  3:18         ` Aleksa Sarai
2022-06-18  9:11           ` Amir Goldstein
2022-06-18 11:19             ` Christian Göttsche
2022-06-18 15:30               ` Amir Goldstein
2022-06-20  6:07             ` Aleksa Sarai
2022-06-20  7:45               ` Amir Goldstein
2022-06-22  2:57                 ` Aleksa Sarai
2022-08-19 18:05                   ` Christian Göttsche
2022-08-19 20:27                     ` Amir Goldstein [this message]
2022-06-08 16:53 ` Andreas Dilger
2022-06-09  4:35   ` Amir Goldstein
2022-06-09  9:14     ` Christian Göttsche

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=CAOQ4uxhiyVixjDnDsMusfAPqP4DkbA0TfmOKGLa_L6T6s1JJjQ@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=cgzones@googlemail.com \
    --cc=cyphar@cyphar.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mszeredi@redhat.com \
    --cc=selinux@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).