Skip to contentSkip to conversation

libceph: fix misjudgement of maximum monitor number

PATCH Applied Chengguang Xu 2 participants 2 messages Feb 11, 2018 – Feb 12, 2018 Ceph common code (libceph)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libceph: fix misjudgement of maximum monitor number

num_mon should allow up to CEPH_MAX_MON in ceph_monmap_decode().

---
 net/ceph/mon_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ceph/mon_client.c +1 -1
index 1547107..b3dac24 100644
@@ -60,7 +60,7 @@ struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
 	num_mon = ceph_decode_32(&p);
 	ceph_decode_need(&p, end, num_mon*sizeof(m->mon_inst[0]), bad);
 
-	if (num_mon >= CEPH_MAX_MON)
+	if (num_mon > CEPH_MAX_MON)
 		goto bad;
 	m = kmalloc(sizeof(*m) + sizeof(m->mon_inst[0])*num_mon, GFP_NOFS);
 	if (m == NULL)
Signature · 1 line
1.8.3.1
maintainer Applied
#1 lore raw
Quoted 12 lines · Chengguang Xu

num_mon should allow up to CEPH_MAX_MON in ceph_monmap_decode().

---
 net/ceph/mon_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ceph/mon_client.c +0 -0
index 1547107..b3dac24 100644

net/ceph/mon_client.c struct ceph_monmap *ceph_monmap_decode(void *p, void *end) · line 66

Quoted 8 lines
net/ceph/mon_client.c +1 -1
@@ -60,7 +60,7 @@ struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
        num_mon = ceph_decode_32(&p);
        ceph_decode_need(&p, end, num_mon*sizeof(m->mon_inst[0]), bad);
 
-       if (num_mon >= CEPH_MAX_MON)
+       if (num_mon > CEPH_MAX_MON)
                goto bad;
        m = kmalloc(sizeof(*m) + sizeof(m->mon_inst[0])*num_mon, GFP_NOFS);
        if (m == NULL)

Applied.

Thanks,

Ilya