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

get_current_cred() increments the reference counter, but the
put_cred() call was missing.

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 ca9b96ae0646e7447fa0617cc91edaa73edda967..cf92b75745e2a5cb3f4f81ac637413302c07263a 100644 (file)
@@ -5736,6 +5736,7 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
 
                err = ceph_mds_auth_match(mdsc, s, cred, tpath);
                if (err < 0) {
+                       put_cred(cred);
                        return err;
                } else if (err > 0) {
                        /* always follow the last auth caps' permision */
@@ -5751,6 +5752,8 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
                }
        }
 
+       put_cred(cred);
+
        doutc(cl, "root_squash_perms %d, rw_perms_s %p\n", root_squash_perms,
              rw_perms_s);
        if (root_squash_perms && rw_perms_s == NULL) {