]> www.infradead.org Git - nvme.git/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)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 25 Nov 2024 14:51:13 +0000 (15:51 +0100)
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>
fs/ceph/mds_client.c

index aa48ac1bcd81ded068e200dd08f4369d4b4629c1..219a2cc2bf3cc2f22a0d76d822df3aef6de8649f 100644 (file)
@@ -5728,6 +5728,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' permission */
@@ -5743,6 +5744,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) {