Skip to content

Commit

Permalink
libceph: NULL deref on crush_decode() error path
Browse files Browse the repository at this point in the history
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: f24e998 ("ceph: OSD client")
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Ilya Dryomov <[email protected]>
Signed-off-by: Ilya Dryomov <[email protected]>
  • Loading branch information
Dan Carpenter authored and idryomov committed May 23, 2017
1 parent b51456a commit 293dffa
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions net/ceph/osdmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,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",
Expand Down

0 comments on commit 293dffa

Please sign in to comment.