]> git.hungrycats.org Git - linux/commitdiff
ceph: pass cred pointer to ceph_mds_auth_match()
authorMax Kellermann <max.kellermann@ionos.com>
Sat, 23 Nov 2024 07:21:20 +0000 (08:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Dec 2024 09:41:05 +0000 (10:41 +0100)
commit 23426309a4064b25a961e1c72961d8bfc7c8c990 upstream.

This eliminates a redundant get_current_cred() call, because
ceph_mds_check_access() has already obtained this pointer.

As a side effect, this also fixes a reference leak in
ceph_mds_auth_match(): by omitting the get_current_cred() call, no
additional cred reference is taken.

Cc: stable@vger.kernel.org
Fixes: 596afb0b8933 ("ceph: add ceph_mds_check_access() helper")
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ceph/mds_client.c

index c4a5fd94bbbb3ba440891a5f0a860260c6e4d0d5..ca9b96ae0646e7447fa0617cc91edaa73edda967 100644 (file)
@@ -5609,9 +5609,9 @@ void send_flush_mdlog(struct ceph_mds_session *s)
 
 static int ceph_mds_auth_match(struct ceph_mds_client *mdsc,
                               struct ceph_mds_cap_auth *auth,
+                              const struct cred *cred,
                               char *tpath)
 {
-       const struct cred *cred = get_current_cred();
        u32 caller_uid = from_kuid(&init_user_ns, cred->fsuid);
        u32 caller_gid = from_kgid(&init_user_ns, cred->fsgid);
        struct ceph_client *cl = mdsc->fsc->client;
@@ -5734,7 +5734,7 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
        for (i = 0; i < mdsc->s_cap_auths_num; i++) {
                struct ceph_mds_cap_auth *s = &mdsc->s_cap_auths[i];
 
-               err = ceph_mds_auth_match(mdsc, s, tpath);
+               err = ceph_mds_auth_match(mdsc, s, cred, tpath);
                if (err < 0) {
                        return err;
                } else if (err > 0) {