linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Donnelly <pdonnell@redhat.com>
To: Ilya Dryomov <idryomov@gmail.com>
Cc: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>,
	 Kotresh Hiremath Ravishankar <khiremat@redhat.com>,
	Viacheslav Dubeyko <vdubeyko@redhat.com>,
	 "ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>,
	"slava@dubeyko.com" <slava@dubeyko.com>,
	 "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	Gregory Farnum <gfarnum@redhat.com>,
	 Alex Markuze <amarkuze@redhat.com>,
	Pavan Rallabhandi <Pavan.Rallabhandi@ibm.com>,
	 Venky Shankar <vshankar@redhat.com>
Subject: Re: [PATCH] ceph: fix kernel crash in ceph_open()
Date: Tue, 2 Dec 2025 15:21:20 -0500	[thread overview]
Message-ID: <CA+2bHPYLsoFCPnhgOsd7VbSAmrbzXPJDiGW1WZWpPZvdduA6xQ@mail.gmail.com> (raw)
In-Reply-To: <CAOi1vP83qU-J4b1HyQ4awYN_F=xQAaP8dGYFfXxnxoryBC1c7w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2931 bytes --]

I started work on a patch and it is largely in agreement with what
Ilya suggested below.

On Tue, Dec 2, 2025 at 6:30 AM Ilya Dryomov <idryomov@gmail.com> wrote:
> Hi Slava,
>
> I think the right solution would be a patch that establishes
> consistency with the userspace client.  What does ceph-fuse do when
> --client_fs option isn't passed?  It's the exact equivalent of
> mds_namespace mount option (--client_mds_namespace is what it used to
> be named), so the kernel client just needs to be made to do exactly the
> same.
>
> After taking a deeper look I doubt that using the default fs_name for
> the comparison would be sufficient and not prone to edge cases.  First,
> even putting the NULL dereference aside, both the existing check by
> Kotresh
>
>     if (auth->match.fs_name && strcmp(auth->match.fs_name, fs_name))
>         /* mismatch */
>
> and your proposed check
>
>     if (!fs_name1 || !fs_name2)
>         /* match */
>
>     if (strcmp(fs_name1, fs_name2))
>         /* mismatch */
>
> aren't equivalent to
>
>   bool match_fs(std::string_view target_fs) const {
>     return fs_name == target_fs || fs_name.empty() || fs_name == "*";
>   }
>
> in src/mds/MDSAuthCaps.h -- "*" isn't handled at all.
>
> Second, I'm not following a reason to only "validate" fs_name against
> mds_namespace option in ceph_mdsmap_decode().  Why not hold onto it and
> actually use it in ceph_mds_auth_match() for the comparison as done in
> src/client/Client.cc?
>
> int Client::mds_check_access(std::string& path, const UserPerm& perms, int mask)
> {
>   ...
>   std::string_view fs_name = mdsmap->get_fs_name();   <---------
>   for (auto& s: cap_auths) {
>     ...
>     if (s.match.match(fs_name, path, perms.uid(), perms.gid(), &gid_list)) {
>       /* match */
>
> AFAIU the default fs_name would come into the picture only in case of
> a super ancient cluster with prior to mdsmap v8 encoding.
>
> I haven't really looked at this code before, so it's possible that
> there are other things that are missing/inconsistent here.  I'd ask
> that the final patch is formally reviewed by Venky and Patrick as
> they were the approvers on https://github.com/ceph/ceph/pull/64550
> in userspace.

We should match the ceph-fuse client behavior.

Attached is the patch (I've not built) which roughly gets us there.
The missing bit will be the "*" glob matching.

In summary, we should definitely start decoding `fs_name` from the
MDSMap and do strict authorizations checks against it. Note that the
`--mds_namespace` should only be used for selecting the file system to
mount and nothing else. It's possible no mds_namespace is specified
but the kernel will mount the only file system that exists which may
have name "foo".


--
Patrick Donnelly, Ph.D.
He / Him / His
Red Hat Partner Engineer
IBM, Inc.
GPG: 19F28A586F808C2402351B93C3301A3E258DD79D

[-- Attachment #2: fs_name.patch --]
[-- Type: application/x-patch, Size: 2299 bytes --]

  reply	other threads:[~2025-12-02 20:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19 19:37 [PATCH] ceph: fix kernel crash in ceph_open() Viacheslav Dubeyko
2025-11-19 22:40 ` Ilya Dryomov
2025-11-19 22:50   ` Viacheslav Dubeyko
     [not found]     ` <CAJ4mKGZexNm--cKsT0sc0vmiAyWrA1a6FtmaGJ6WOsg8d_2R3w@mail.gmail.com>
2025-11-19 23:16       ` Viacheslav Dubeyko
2025-11-20 14:20         ` Kotresh Hiremath Ravishankar
2025-11-20 20:17           ` Viacheslav Dubeyko
2025-11-24 19:18             ` Kotresh Hiremath Ravishankar
2025-11-24 21:12               ` Viacheslav Dubeyko
2025-11-27  7:33                 ` Kotresh Hiremath Ravishankar
2025-12-01 20:04                   ` Viacheslav Dubeyko
2025-12-02 11:30                     ` Ilya Dryomov
2025-12-02 20:21                       ` Patrick Donnelly [this message]
2025-12-03 19:48                         ` Viacheslav Dubeyko

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=CA+2bHPYLsoFCPnhgOsd7VbSAmrbzXPJDiGW1WZWpPZvdduA6xQ@mail.gmail.com \
    --to=pdonnell@redhat.com \
    --cc=Pavan.Rallabhandi@ibm.com \
    --cc=Slava.Dubeyko@ibm.com \
    --cc=amarkuze@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=gfarnum@redhat.com \
    --cc=idryomov@gmail.com \
    --cc=khiremat@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=slava@dubeyko.com \
    --cc=vdubeyko@redhat.com \
    --cc=vshankar@redhat.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;
as well as URLs for NNTP newsgroup(s).