From: Dan Carpenter Date: Tue, 23 May 2017 14:25:10 +0000 (+0300) Subject: libceph: NULL deref on crush_decode() error path X-Git-Tag: v3.2.93~63 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af0b6ca74ba5349f13faf0159ad4f6de214d448a;p=pandora-kernel.git libceph: NULL deref on crush_decode() error path commit 293dffaad8d500e1a5336eeb90d544cf40d4fbd8 upstream. If there is not enough space then ceph_decode_32_safe() does a goto bad. We need to return an error code in that situation. The current code returns ERR_PTR(0) which is NULL. The callers are not expecting that and it results in a NULL dereference. Fixes: f24e9980eb86 ("ceph: OSD client") Signed-off-by: Dan Carpenter Reviewed-by: Ilya Dryomov Signed-off-by: Ilya Dryomov Signed-off-by: Ben Hutchings --- diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index bb38a3c51912..e31529d9d121 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -268,6 +268,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end) u32 yes; struct crush_rule *r; + err = -EINVAL; ceph_decode_32_safe(p, end, yes, bad); if (!yes) { dout("crush_decode NO rule %d off %x %p to %p\n",