From: Nathaniel Yazdani Date: Mon, 5 Aug 2013 04:04:30 +0000 (-0700) Subject: ceph: fix null pointer dereference X-Git-Tag: firefly_0821_release~3679^2~3153 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=acb2e930c72a1d38504d6d9c1f338562bbb9aa55;p=firefly-linux-kernel-4.4.55.git ceph: fix null pointer dereference commit c338c07c51e3106711fad5eb599e375eadb6855d upstream. When register_session() is given an out-of-range argument for mds, ceph_mdsmap_get_addr() will return a null pointer, which would be given to ceph_con_open() & be dereferenced, causing a kernel oops. This fixes bug #4685 in the Ceph bug tracker . Signed-off-by: Nathaniel Yazdani Reviewed-by: Sage Weil Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 63c789eb1e3e..d6a536886472 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -414,6 +414,9 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc, { struct ceph_mds_session *s; + if (mds >= mdsc->mdsmap->m_max_mds) + return ERR_PTR(-EINVAL); + s = kzalloc(sizeof(*s), GFP_NOFS); if (!s) return ERR_PTR(-ENOMEM);