ceph: ensure we return an error when parsing corrupt mdsmap
PATCH 1/1 ceph: ensure we return an error when parsing corrupt mdsmap
Commit ba5e57de7b20 (ceph: reconnect to the export targets on new mdsmaps) changed ceph_mdsmap_decode to "goto corrupt" when given a bogus mds rank in the export targets. It did not set the err variable however, which caused that function to return a NULL pointer instead of a proper ERR_PTR value for the error.
Fix this by setting err before doing the "goto corrupt".
URL: https://tracker.ceph.com/issues/52436
--- fs/ceph/mdsmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
I'll plan to fold this change into the original patch since it hasn't been merged yet. Let me know if you have objections.
fs/ceph/mdsmap.c +3 -1
@@ -263,8 +263,10 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end, bool msgr2) goto nomem;for (j =0 ; j < num_export_targets; j++) { target =ceph_decode_32 (&pexport_targets); -if (target >= m->possible_max_rank) +if (target >= m->possible_max_rank) { + err = -EIO ; goto corrupt; + } info->export_targets[j] = target; } }else {
Signature · 1 line
2.31.1
Quoted 24 lines · Jeff Layton
Commit
ba5e57de7b20(ceph: reconnect to the export targets on new mdsmaps) changedceph_mdsmap_decodeto "goto corrupt" when given a bogus mds rank in the export targets. It did not set the err variable however, which caused that function to return a NULL pointer instead of a properERR_PTRvalue for the error.Fix this by setting err before doing the "goto corrupt".
URL: https://tracker.ceph.com/issues/52436
Fixes ba5e57de7b20 ("ceph: reconnect to the export targets on new mdsmaps")Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mdsmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)I'll plan to fold this change into the original patch since it hasn't been merged yet. Let me know if you have objections.
fs/ceph/mdsmap.c +0
-0@@ -263,8 +263,10 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end, bool msgr2) goto nomem;
fs/ceph/mdsmap.c struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end, bool msgr2) · line 272
Quoted 10 lines
fs/ceph/mdsmap.c +3
-1for (j =0 ; j < num_export_targets; j++) { target =ceph_decode_32 (&pexport_targets); -if (target >= m->possible_max_rank) +if (target >= m->possible_max_rank) { + err = -EIO ; goto corrupt; + } info->export_targets[j] = target; } }else {
Make sense and LGTM.