From: "Mickaël Salaün" <mic@digikod.net>
To: Paul Moore <paul@paul-moore.com>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: "John Johansen" <john.johansen@canonical.com>,
"Al Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
"Darrick J . Wong" <djwong@kernel.org>,
"Eric Paris" <eparis@parisplace.org>,
"James Morris" <jmorris@namei.org>,
"Kentaro Takeda" <takedakn@nttdata.co.jp>,
"Miklos Szeredi" <miklos@szeredi.hu>,
"Serge E . Hallyn" <serge@hallyn.com>,
"Stephen Smalley" <stephen.smalley.work@gmail.com>,
"Steve French" <sfrench@samba.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org,
"Mickaël Salaün" <mic@linux.microsoft.com>,
selinux@vger.kernel.org,
"Casey Schaufler" <casey@schaufler-ca.com>
Subject: Re: [PATCH v1] fs: Fix inconsistent f_mode
Date: Mon, 14 Mar 2022 09:22:33 +0100 [thread overview]
Message-ID: <bdc3f565-9deb-504e-a904-639b9b2c7517@digikod.net> (raw)
In-Reply-To: <CAHC9VhQqx7B+6Ji_92eMZ1o9O_yaDQQoPVw92Av0Zznv7i8F8w@mail.gmail.com>
On 12/03/2022 16:17, Paul Moore wrote:
> On Fri, Mar 11, 2022 at 8:35 PM Tetsuo Handa
> <penguin-kernel@i-love.sakura.ne.jp> wrote:
>> On 2022/03/12 7:15, Paul Moore wrote:
>>> The silence on this has been deafening :/ No thoughts on fixing, or
>>> not fixing OPEN_FMODE(), Al?
>>
>> On 2022/03/01 19:15, Mickaël Salaün wrote:
>>>
>>> On 01/03/2022 10:22, Christian Brauner wrote:
>>>> That specific part seems a bit risky at first glance. Given that the
>>>> patch referenced is from 2009 this means we've been allowing O_WRONLY |
>>>> O_RDWR to succeed for almost 13 years now.
>>>
>>> Yeah, it's an old bug, but we should keep in mind that a file descriptor
>>> created with such flags cannot be used to read nor write. However,
>>> unfortunately, it can be used for things like ioctl, fstat, chdir… I
>>> don't know if there is any user of this trick.
>>
>> I got a reply from Al at https://lkml.kernel.org/r/20090212032821.GD28946@ZenIV.linux.org.uk
>> that sys_open(path, 3) is for ioctls only. And I'm using this trick when opening something
>> for ioctls only.
>
> Thanks Tetsuo, that's helpful. After reading your email I went
> digging around to see if this was documented anywhere, and buried in
> the open(2) manpage, towards the bottom under the "File access mode"
> header, is this paragraph:
>
> "Linux reserves the special, nonstandard access mode 3 (binary 11)
> in flags to mean: check for read and write permission on the file
> and return a file descriptor that can't be used for reading or
> writing. This nonstandard access mode is used by some Linux
> drivers to return a file descriptor that is to be used only for
> device-specific ioctl(2) operations."
Interesting, I missed the reference to this special value in the man page.
>
> I learned something new today :) With this in mind it looks like
> doing a SELinux file:ioctl check is the correct thing to do.
Indeed, SELinux uses it in an early ioctl check, but it still seems
inconsistent (without being a bug) with the handling of the other value
of this flag. This FD can also be used for chdir or other inode-related
actions, which may not involve ioctl.
However, it seems there is a more visible inconsistency with the way
Tomoyo checks for read, write (because of the ACC_MODE use) *and* ioctl
rights for an ioctl action. At least, the semantic is not the same and
is not reflected in the documentation.
Because AppArmor and Landlock don't support ioctl, this looks fine for them.
next prev parent reply other threads:[~2022-03-14 8:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 21:59 Mickaël Salaün
2022-03-01 9:22 ` Christian Brauner
2022-03-01 10:15 ` Mickaël Salaün
2022-03-09 21:31 ` Paul Moore
2022-03-10 0:36 ` John Johansen
2022-03-11 22:15 ` Paul Moore
2022-03-12 1:34 ` Tetsuo Handa
2022-03-12 15:17 ` Paul Moore
2022-03-14 8:22 ` Mickaël Salaün [this message]
2022-03-13 0:44 ` Al Viro
2022-03-13 0:42 ` Al Viro
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=bdc3f565-9deb-504e-a904-639b9b2c7517@digikod.net \
--to=mic@digikod.net \
--cc=brauner@kernel.org \
--cc=casey@schaufler-ca.com \
--cc=djwong@kernel.org \
--cc=eparis@parisplace.org \
--cc=jmorris@namei.org \
--cc=john.johansen@canonical.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@linux.microsoft.com \
--cc=miklos@szeredi.hu \
--cc=paul@paul-moore.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=selinux@vger.kernel.org \
--cc=serge@hallyn.com \
--cc=sfrench@samba.org \
--cc=stephen.smalley.work@gmail.com \
--cc=takedakn@nttdata.co.jp \
--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
all inboxes | Powered by JetHome®