Patch "ceph: fix possible null-pointer dereference in ceph_mdsmap_decode()" has been added to the 5.13-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ceph: fix possible null-pointer dereference in ceph_mdsmap_decode()

to the 5.13-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ceph-fix-possible-null-pointer-dereference-in-ceph_m.patch
and it can be found in the queue-5.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 77837783fc16dbeccf04dca9c7ba2d6c40def849
Author: Tuo Li <islituo@xxxxxxxxx>
Date:   Thu Aug 5 08:14:34 2021 -0700

    ceph: fix possible null-pointer dereference in ceph_mdsmap_decode()
    
    [ Upstream commit a9e6ffbc5b7324b6639ee89028908b1e91ceed51 ]
    
    kcalloc() is called to allocate memory for m->m_info, and if it fails,
    ceph_mdsmap_destroy() behind the label out_err will be called:
      ceph_mdsmap_destroy(m);
    
    In ceph_mdsmap_destroy(), m->m_info is dereferenced through:
      kfree(m->m_info[i].export_targets);
    
    To fix this possible null-pointer dereference, check m->m_info before the
    for loop to free m->m_info[i].export_targets.
    
    [ jlayton: fix up whitespace damage
               only kfree(m->m_info) if it's non-NULL ]
    
    Reported-by: TOTE Robot <oslab@xxxxxxxxxxxxxxx>
    Signed-off-by: Tuo Li <islituo@xxxxxxxxx>
    Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
    Signed-off-by: Ilya Dryomov <idryomov@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/ceph/mdsmap.c b/fs/ceph/mdsmap.c
index abd9af7727ad..3c444b9cb17b 100644
--- a/fs/ceph/mdsmap.c
+++ b/fs/ceph/mdsmap.c
@@ -394,9 +394,11 @@ void ceph_mdsmap_destroy(struct ceph_mdsmap *m)
 {
 	int i;
 
-	for (i = 0; i < m->possible_max_rank; i++)
-		kfree(m->m_info[i].export_targets);
-	kfree(m->m_info);
+	if (m->m_info) {
+		for (i = 0; i < m->possible_max_rank; i++)
+			kfree(m->m_info[i].export_targets);
+		kfree(m->m_info);
+	}
 	kfree(m->m_data_pg_pools);
 	kfree(m);
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux